Deno support #2743
Replies: 2 comments 2 replies
-
It'd be interesting, yes. I can see a way to launch a deno instance as a child process, but how would we provide AVA's How does this relate to ESM modules? What are the differences between the two platforms in terms of the built-in API? |
Beta Was this translation helpful? Give feedback.
-
Poor man's test wrapper: /** @typedef {import('ava').TestFn} AvaTestFn */
// @ts-ignore Custom cast
export default await (async () => {
if ('Deno' in globalThis) {
const denoAsserts = await import('https://deno.land/std@0.178.0/testing/asserts.ts');
/**
*
* @param {string} title
* @param {import('ava').ImplementationFn<any, any>} implementation
*/
// eslint-disable-next-line no-inner-declarations
function test(title, implementation) {
Deno.test(title, async (t) => {
/** @type {import('ava').ExecutionContext} T */
const wrapper = {
assert: denoAsserts.assertStrictEquals,
deepEqual: denoAsserts.assertEquals,
// like
fail: denoAsserts.fail,
false(actual, message) {
denoAsserts.assertStrictEquals(actual, false, message);
return true;
},
falsy(actual, message) {
denoAsserts.assertStrictEquals(!actual, true, message);
return true;
},
is: denoAsserts.assertStrictEquals,
not(actual, expected) {
denoAsserts.assertStrictEquals(!Object.is(actual, expected), true);
},
notDeepEqual: denoAsserts.assertNotEquals,
notRegex: denoAsserts.notMatch,
notThrows(fn, message) {
try {
fn();
} catch {
this.fail(message);
}
},
async notThrowsAsync(fn, message) {
try {
await fn();
} catch {
this.fail(message);
}
},
pass(message) {
denoAsserts.assert(true, message);
},
regex: denoAsserts.assertMatch,
// snapshot
throws: denoAsserts.assertThrows,
async throwsAsync(fn, expectations, message) {
try {
await fn();
this.fail(message);
} catch (e) {
this.throws(() => { throw e; }, expectations, message);
}
},
true(actual, message) {
denoAsserts.assertStrictEquals(actual, true, message);
},
truthy(actual, message) {
denoAsserts.assert(actual, message);
},
log: console.debug,
};
await implementation(wrapper);
});
}
return test;
}
if ('window' in globalThis) {
// TODO: Tap into browser-based tester
return null;
}
// Node
const ava = await import('ava');
return ava.default;
})(); Instead of |
Beta Was this translation helpful? Give feedback.
-
It would be great, when
ava
can run deno (https://deno.land/) modules after ESM-modules are fully implemented. When testing a deno-project we could use all features (watch-mode, hooks, concurrency, snapshots).My idea was to use deno as new runner-process and node for the surrounding (reporting, snapshots ...).
Beta Was this translation helpful? Give feedback.
All reactions