add done() call

pull/7076/head
baseballyama 5 years ago
parent 921d998c1b
commit 21c07de407

@ -35,7 +35,7 @@ describe('runtime', () => {
svelte = loadSvelte(false); svelte = loadSvelte(false);
svelte$ = loadSvelte(true); svelte$ = loadSvelte(true);
require.extensions['.svelte'] = function(module, filename) { require.extensions['.svelte'] = function (module, filename) {
const options = Object.assign({ const options = Object.assign({
filename filename
}, compileOptions); }, compileOptions);
@ -65,7 +65,7 @@ describe('runtime', () => {
} }
const testName = `${dir} ${hydrate ? `(with hydration${from_ssr_html ? ' from ssr rendered html' : ''})` : ''}`; const testName = `${dir} ${hydrate ? `(with hydration${from_ssr_html ? ' from ssr rendered html' : ''})` : ''}`;
(config.skip ? it.skip : solo ? it.only : it)(testName, () => { (config.skip ? it.skip : solo ? it.only : it)(testName, (done) => {
if (failed.has(dir)) { if (failed.has(dir)) {
// this makes debugging easier, by only printing compiled output once // this makes debugging easier, by only printing compiled output once
throw new Error('skipping test, already failed'); throw new Error('skipping test, already failed');
@ -96,7 +96,7 @@ describe('runtime', () => {
glob('**/*.svelte', { cwd }).forEach(file => { glob('**/*.svelte', { cwd }).forEach(file => {
if (file[0] === '_') return; if (file[0] === '_') return;
const dir = `${cwd}/_output/${hydrate ? 'hydratable' : 'normal'}`; const dir = `${cwd}/_output/${hydrate ? 'hydratable' : 'normal'}`;
const out = `${dir}/${file.replace(/\.svelte$/, '.js')}`; const out = `${dir}/${file.replace(/\.svelte$/, '.js')}`;
if (fs.existsSync(out)) { if (fs.existsSync(out)) {
@ -120,7 +120,7 @@ describe('runtime', () => {
} }
}); });
return Promise.resolve() Promise.resolve()
.then(() => { .then(() => {
// hack to support transition tests // hack to support transition tests
clear_loops(); clear_loops();
@ -203,7 +203,7 @@ describe('runtime', () => {
} }
if (config.test) { if (config.test) {
return Promise.resolve(config.test({ config.test({
assert, assert,
component, component,
mod, mod,
@ -211,13 +211,12 @@ describe('runtime', () => {
window, window,
raf, raf,
compileOptions compileOptions
})).then(() => {
component.$destroy();
if (unhandled_rejection) {
throw unhandled_rejection;
}
}); });
component.$destroy();
if (unhandled_rejection) {
throw unhandled_rejection;
}
} else { } else {
component.$destroy(); component.$destroy();
assert.htmlEqual(target.innerHTML, ''); assert.htmlEqual(target.innerHTML, '');
@ -245,6 +244,7 @@ describe('runtime', () => {
.catch(err => { .catch(err => {
// print a clickable link to open the directory // print a clickable link to open the directory
err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), cwd)}/main.svelte`; err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), cwd)}/main.svelte`;
done();
throw err; throw err;
}) })
.then(() => { .then(() => {
@ -255,6 +255,7 @@ describe('runtime', () => {
flush(); flush();
if (config.after_test) config.after_test(); if (config.after_test) config.after_test();
done();
}); });
}); });
} }

@ -52,7 +52,7 @@ describe('ssr', () => {
throw new Error('Forgot to remove `solo: true` from test'); throw new Error('Forgot to remove `solo: true` from test');
} }
(solo ? it.only : it)(dir, () => { (solo ? it.only : it)(dir, (done) => {
dir = path.resolve(`${__dirname}/samples`, dir); dir = path.resolve(`${__dirname}/samples`, dir);
cleanRequireCache(); cleanRequireCache();
@ -131,6 +131,7 @@ describe('ssr', () => {
err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), dir)}/main.svelte`; err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), dir)}/main.svelte`;
throw err; throw err;
} finally { } finally {
done();
set_current_component(null); set_current_component(null);
} }
}); });

Loading…
Cancel
Save