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");
}
(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)) {
// this makes debugging easier, by only printing compiled output once
throw new Error('skipping test, already failed');
@ -105,7 +105,8 @@ describe("runtime", () => {
const window = env();
try {
return Promise.resolve()
.then(() => {
// set of hacks to support transition tests
transitionManager.running = false;
transitionManager.transitions = [];
@ -178,12 +179,13 @@ describe("runtime", () => {
}
if (config.test) {
await config.test(assert, component, target, window, raf);
return config.test(assert, component, target, window, raf);
} else {
component.destroy();
assert.equal(target.innerHTML, "");
}
} catch (err) {
})
.catch(err => {
if (config.error && !unintendedError) {
config.error(assert, err);
} else {
@ -191,10 +193,11 @@ describe("runtime", () => {
showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate }, svelte); // eslint-disable-line no-console
throw err;
}
}
})
.then(() => {
if (config.show) showOutput(cwd, { shared, format: 'cjs', hydratable: hydrate }, svelte);
});
});
}
const shared = path.resolve("shared.js");

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