-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
101 lines (90 loc) · 4.35 KB
/
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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import assert from 'node:assert/strict'
import { exec } from 'node:child_process'
import { test } from 'node:test'
test('node tests', async (t) => {
await t.test('test node version deprecation check', (_t, done) => {
exec('node ./dist/cli.mjs node', (_error, stdout, stderr) => {
assert.ok(/node version/.test(stdout) || /node version/.test(stderr), 'Expected "node version" to be mentioned in output.')
done()
})
})
})
test('current tests', async (t) => {
await t.test('check if no deprecation warning is shown', (_t, done) => {
exec('node ./dist/cli.mjs current', (_error, _stdout, stderr) => {
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
done()
})
})
await t.test('check if deprecation warning is shown if deprecated package is installed', (_t, done) => {
exec('pnpm i request --force && node ./dist/cli.mjs current', { timeout: 160000 }, (_error, _stdout, stderr) => {
assert.ok(/request has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
// Cleanup: Undo the installation
exec('pnpm remove request')
done()
})
})
await t.test('check if no deprecation warning is shown if ignore deprecated package', (_t, done) => {
exec('pnpm i request --force && node ./dist/cli.mjs current --ignore request', { timeout: 160000 }, (_error, _stdout, stderr) => {
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
// Cleanup: Undo the installation
exec('pnpm remove request')
done()
})
})
await t.test('check if exit the program if the package is deprecated', (_t, done) => {
exec('pnpm i request tslint --force && node ./dist/cli.mjs current --failfast', { timeout: 160000 }, (_error, _stdout, stderr) => {
assert.ok(/request has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
assert.ok(!/tslint has been deprecated/.test(stderr), 'Expected process.exit(1), only "request has been deprecated".')
// Cleanup: Undo the installation
exec('pnpm remove request tslint')
done()
})
})
})
test('global tests', async (t) => {
await t.test('check if no deprecation warning is shown', (_t, done) => {
exec('node ./dist/cli.mjs global', (_error, _stdout, stderr) => {
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
done()
})
})
await t.test('check if no deprecation warning is shown if ignore deprecated package', (_t, done) => {
exec('pnpm i request --force -g && node ./dist/cli.mjs global --manager pnpm --ignore request', { timeout: 160000 }, (_error, _stdout, stderr) => {
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
// Cleanup: Undo the installation
exec('pnpm remove request -g')
done()
})
})
})
test('package tests', async (t) => {
await t.test('check if deprecated package gets detected', (_t, done) => {
exec('node ./dist/cli.mjs package request', (_error, _stdout, stderr) => {
assert.ok(/has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
done()
})
})
await t.test('check if not deprecated package does not get detected as deprecated', (_t, done) => {
exec('node ./dist/cli.mjs package eslint', (_error, _stdout, stderr) => {
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
done()
})
})
})
test('config tests', async (t) => {
await t.test('check config --list', (_t, done) => {
exec('node ./dist/cli.mjs config -- --list', (_error, stdout, _stderr) => {
assert.ok(/inspect and modify the config/.test(stdout), 'Expected "inspect and modify the config" to be mentioned in config list.')
done()
})
})
})
test('help tests', async (t) => {
await t.test('check help', (_t, done) => {
exec('node ./dist/cli.mjs help', (_error, stdout, _stderr) => {
assert.ok(/display help for command/.test(stdout), 'Expected "display help for command" to be mentioned in help.')
done()
})
})
})