-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsuite.test.js
More file actions
76 lines (62 loc) · 1.23 KB
/
suite.test.js
File metadata and controls
76 lines (62 loc) · 1.23 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {suite} from '#suite'
const test = suite(import.meta, {
status: '',
beforeAll() {
this.status = 'beforeAll'
},
beforeEach() {
if (this.status !== 'beforeAll' && this.status !== 'afterEach')
throw new Error(`hooks did not run, ${this.status}`)
this.status = 'beforeEach'
},
afterEach() {
this.status = 'afterEach'
},
afterAll() {
if (this.status !== 'afterEach')
throw new Error(`hooks did not run, ${this.status}`)
}
})
test('before each', ctx => {
test.equal(ctx.status, 'beforeEach')
})
test('truthy', () => {
test.ok(true)
})
test('falsy', () => {
test.not.ok(false)
})
test('equal', () => {
test.equal({a: 1}, {a: 1})
})
test('not equal', () => {
test.not.equal({a: 1}, {a: 2})
})
test('strict equal', () => {
test.is(1, 1)
})
test('not strict equal', () => {
test.not.is(1, '1')
})
test('throws', () => {
test.throws(() => {
throw new Error('ok')
})
})
test('throws message', () => {
test.throws(() => {
throw new Error('a message')
}, 'message')
})
test.skip('skip', () => {
test.ok(false)
})
test('async', async () => {
test.ok(true)
})
test('options', { timeout: 1000 }, () => {
test.ok(true)
})
/*test.only('only', () => {
test.ok(true)
})*/