forked from avajs/ava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
38 lines (31 loc) 路 911 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
32
33
34
35
36
37
38
import fs from 'node:fs/promises';
import {fileURLToPath} from 'node:url';
import test from '@ava/test';
import {fixture} from '../helpers/exec.js';
test('internal events are emitted', async t => {
await fixture();
const result = JSON.parse(await fs.readFile(fileURLToPath(new URL('fixtures/internal-events.json', import.meta.url))));
t.like(result[0], {
type: 'run',
plan: {
files: [
fileURLToPath(new URL('fixtures/test.js', import.meta.url)),
],
},
});
const testPassedEvent = result.find(event => event.type === 'stateChange' && event.stateChange.type === 'test-passed');
t.like(testPassedEvent, {
type: 'stateChange',
stateChange: {
type: 'test-passed',
title: 'placeholder',
testFile: fileURLToPath(new URL('fixtures/test.js', import.meta.url)),
},
});
t.like(result[result.length - 1], {
type: 'stateChange',
stateChange: {
type: 'end',
},
});
});