-
Notifications
You must be signed in to change notification settings - Fork 79
/
test.js
31 lines (23 loc) · 826 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const path = require('node:path');
const { once } = require('node:events');
const test = require('ava');
const Bree = require('../../../src');
const root = path.join(__dirname, 'jobs');
test('defaultRootIndex as an ESM module', async (t) => {
const bree = new Bree({
root,
defaultRootIndex: 'index.mjs'
});
await bree.run('job');
await once(bree.workers.get('job'), 'online');
const [code] = await once(bree.workers.get('job'), 'exit');
t.is(code, 0);
});
test('defaultRootIndex as an ESM module throws error when no default export', async (t) => {
const bree = new Bree({
root: path.join(__dirname, 'jobs-no-default-export'),
defaultRootIndex: 'index.mjs'
});
const err = await t.throwsAsync(bree.run('job'));
t.regex(err.message, /Root index file missing default export at/);
});