1
- /* eslint-disable no-console */
2
1
import assert from 'node:assert/strict'
3
2
import { exec } from 'node:child_process'
3
+ import process from 'node:process'
4
4
import { test } from 'node:test'
5
5
6
- console . log ( 'Running tests...' )
7
-
8
6
test ( 'current tests' , async ( t ) => {
9
- await t . todo ( 'check if deprecation warning is shown' , ( _t , done ) => {
10
- exec ( 'npm i request && npm run dev current' , { timeout : 60000 } , ( _error , _stdout , stderr ) => {
11
- assert . ok ( / h a s b e e n d e p r e c a t e d / . test ( stderr ) , 'Expected "has been deprecated" to be mentioned in deprecation warning.' )
12
- done ( )
13
- } )
14
- } )
15
-
16
7
await t . test ( 'check if no deprecation warning is shown' , ( _t , done ) => {
17
- exec ( 'npm run dev current' , ( _error , _stdout , stderr ) => {
8
+ exec ( 'node ./dist/cli.mjs current' , ( _error , _stdout , stderr ) => {
18
9
assert . ok ( ! / h a s b e e n d e p r e c a t e d / . test ( stderr ) , 'Not expected "has been deprecated" to be mentioned in deprecation warning.' )
19
10
done ( )
20
11
} )
21
12
} )
22
13
14
+ await t . test ( 'check if deprecation warning is shown if deprecated package is installed' , ( _t , done ) => {
15
+ if ( process . version . startsWith ( 'v16' ) ) {
16
+ exec ( 'npx pnpm@8 i request && node ./dist/cli.mjs current' , { timeout : 160000 } , ( _error , _stdout , stderr ) => {
17
+ assert . ok ( / r e q u e s t h a s b e e n d e p r e c a t e d / . test ( stderr ) , 'Expected "has been deprecated" to be mentioned in deprecation warning.' )
18
+ done ( )
19
+ } )
20
+ }
21
+ else {
22
+ exec ( 'npx pnpm i request && node ./dist/cli.mjs current' , { timeout : 160000 } , ( _error , _stdout , stderr ) => {
23
+ assert . ok ( / r e q u e s t h a s b e e n d e p r e c a t e d / . test ( stderr ) , 'Expected "has been deprecated" to be mentioned in deprecation warning.' )
24
+ done ( )
25
+ } )
26
+ }
27
+ } )
28
+
23
29
await t . test ( 'check if node version is mentioned in output' , ( _t , done ) => {
24
- exec ( 'npm run dev current' , ( _error , stdout , _stderr ) => {
25
- assert . ok ( / n o d e v e r s i o n / . test ( stdout ) , 'Expected "node version" to be mentioned in output.' )
30
+ exec ( 'node ./dist/cli.mjs current' , ( _error , stdout , stderr ) => {
31
+ assert . ok ( / n o d e v e r s i o n / . test ( stdout ) || / n o d e v e r s i o n / . test ( stderr ) , 'Expected "node version" to be mentioned in output.' )
26
32
done ( )
27
33
} )
28
34
} )
29
35
} )
30
36
31
37
test ( 'global tests' , async ( t ) => {
32
38
await t . test ( 'check if no deprecation warning is shown' , ( _t , done ) => {
33
- exec ( 'npm run dev global' , ( _error , _stdout , stderr ) => {
39
+ exec ( 'node ./dist/cli.mjs global' , ( _error , _stdout , stderr ) => {
34
40
assert . ok ( ! / h a s b e e n d e p r e c a t e d / . test ( stderr ) , 'Not expected "has been deprecated" to be mentioned in deprecation warning.' )
35
41
done ( )
36
42
} )
@@ -39,14 +45,14 @@ test('global tests', async (t) => {
39
45
40
46
test ( 'package tests' , async ( t ) => {
41
47
await t . test ( 'check if deprecated package gets detected' , ( t , done ) => {
42
- exec ( 'npm run dev package request' , ( _error , _stdout , stderr ) => {
48
+ exec ( 'node ./dist/cli.mjs package request' , ( _error , _stdout , stderr ) => {
43
49
assert . ok ( / h a s b e e n d e p r e c a t e d / . test ( stderr ) , 'Expected "has been deprecated" to be mentioned in deprecation warning.' )
44
50
done ( )
45
51
} )
46
52
} )
47
53
48
54
await t . test ( 'check if not deprecated package does not get detected as deprecated' , ( t , done ) => {
49
- exec ( 'npm run dev package eslint' , ( _error , _stdout , stderr ) => {
55
+ exec ( 'node ./dist/cli.mjs package eslint' , ( _error , _stdout , stderr ) => {
50
56
assert . ok ( ! / h a s b e e n d e p r e c a t e d / . test ( stderr ) , 'Not expected "has been deprecated" to be mentioned in deprecation warning.' )
51
57
done ( )
52
58
} )
@@ -55,16 +61,16 @@ test('package tests', async (t) => {
55
61
56
62
test ( 'config tests' , async ( t ) => {
57
63
await t . test ( 'check config --list' , ( _t , done ) => {
58
- exec ( 'npm run dev config -- --list' , ( _error , stdout , _stderr ) => {
59
- assert . ok ( / l a t e s t V e r s i o n / . test ( stdout ) , 'Expected "latestVersion " to be mentioned in config list.' )
64
+ exec ( 'node ./dist/cli.mjs config -- --list' , ( _error , stdout , _stderr ) => {
65
+ assert . ok ( / i n s p e c t a n d m o d i f y t h e c o n f i g / . test ( stdout ) , 'Expected "inspect and modify the config " to be mentioned in config list.' )
60
66
done ( )
61
67
} )
62
68
} )
63
69
} )
64
70
65
71
test ( 'help tests' , async ( t ) => {
66
72
await t . test ( 'check help' , ( _t , done ) => {
67
- exec ( 'npm run dev help' , ( _error , stdout , _stderr ) => {
73
+ exec ( 'node ./dist/cli.mjs help' , ( _error , stdout , _stderr ) => {
68
74
assert . ok ( / d i s p l a y h e l p f o r c o m m a n d / . test ( stdout ) , 'Expected "display help for command" to be mentioned in help.' )
69
75
done ( )
70
76
} )
0 commit comments