ditch async/await in tests, so that they run in node 6

pull/952/head
Rich Harris 7 years ago
parent 8a0813e96b
commit ccef13a2d5

@ -51,7 +51,7 @@ describe("runtime", () => {
throw new Error("Forgot to remove `solo: true` from test"); throw new Error("Forgot to remove `solo: true` from test");
} }
(config.skip ? it.skip : config.solo ? it.only : it)(`${dir} (${shared ? 'shared' : 'inline'} helpers)`, async () => { (config.skip ? it.skip : config.solo ? it.only : it)(`${dir} (${shared ? 'shared' : 'inline'} helpers)`, () => {
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');
@ -105,7 +105,8 @@ describe("runtime", () => {
const window = env(); const window = env();
try { return Promise.resolve()
.then(() => {
// set of hacks to support transition tests // set of hacks to support transition tests
transitionManager.running = false; transitionManager.running = false;
transitionManager.transitions = []; transitionManager.transitions = [];
@ -178,12 +179,13 @@ describe("runtime", () => {
} }
if (config.test) { if (config.test) {
await config.test(assert, component, target, window, raf); return config.test(assert, component, target, window, raf);
} else { } else {
component.destroy(); component.destroy();
assert.equal(target.innerHTML, ""); assert.equal(target.innerHTML, "");
} }
} catch (err) { })
.catch(err => {
if (config.error && !unintendedError) { if (config.error && !unintendedError) {
config.error(assert, err); config.error(assert, err);
} else { } else {
@ -191,10 +193,11 @@ describe("runtime", () => {
showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate }, svelte); // eslint-disable-line no-console showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate }, svelte); // eslint-disable-line no-console
throw err; throw err;
} }
} })
.then(() => {
if (config.show) showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate }, svelte); if (config.show) showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate }, svelte);
}); });
});
} }
const shared = path.resolve("shared.js"); const shared = path.resolve("shared.js");

@ -13,10 +13,11 @@ export default {
<p>loading...</p> <p>loading...</p>
`, `,
async test(assert, component, target) { test(assert, component, target) {
fulfil(42); fulfil(42);
await thePromise;
return thePromise
.then(() => {
assert.htmlEqual(target.innerHTML, ` assert.htmlEqual(target.innerHTML, `
<p>the value is 42</p> <p>the value is 42</p>
`); `);
@ -37,14 +38,12 @@ export default {
reject(new Error('something broke')); reject(new Error('something broke'));
try { return thePromise.catch(() => {});
await thePromise; })
} catch (err) { .then(() => {
// do nothing
}
assert.htmlEqual(target.innerHTML, ` assert.htmlEqual(target.innerHTML, `
<p>oh no! something broke</p> <p>oh no! something broke</p>
`); `);
});
} }
}; };
Loading…
Cancel
Save