Skip to content

Commit 67c9f8e

Browse files
Run tests with node 16
1 parent 5eb55dd commit 67c9f8e

File tree

2 files changed

+66
-28
lines changed

2 files changed

+66
-28
lines changed

.github/workflows/automated-tests.yaml

+41-9
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
test:
15+
build:
1616
runs-on: ubuntu-latest
1717
timeout-minutes: 30
1818
strategy:
1919
matrix:
20-
node-version: [22, 20, 18]
20+
node-version: [22]
2121

2222
steps:
2323
- name: Checkout code
@@ -31,14 +31,46 @@ jobs:
3131
check-latest: true
3232
cache: npm
3333

34-
- name: Install pnpm
35-
run: npm install -g pnpm
36-
3734
- name: Install dependencies
38-
run: pnpm --silent install
35+
run: npx pnpm install
36+
37+
- name: Build project
38+
run: npx pnpm run build
39+
40+
- name: Save build artifacts
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: build-artifacts
44+
path: dist/cli.mjs
45+
46+
test:
47+
runs-on: ubuntu-latest
48+
needs: build
49+
timeout-minutes: 30
50+
strategy:
51+
matrix:
52+
node-version: [22, 20, 18, 16]
3953

40-
- name: Check linting
41-
run: pnpm run lint
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Use Node.js ${{ matrix.node-version }}
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: ${{ matrix.node-version }}
62+
check-latest: true
63+
64+
- name: Download build artifacts
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: build-artifacts
68+
path: dist/cli.mjs
4269

4370
- name: Run tests
44-
run: pnpm run test
71+
run: |
72+
if [[ ${{ matrix.node-version }} == 16 ]]; then
73+
npx pnpm@8 run test
74+
else
75+
npx pnpm run test
76+
fi

test.js

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
1-
/* eslint-disable no-console */
21
import assert from 'node:assert/strict'
32
import { exec } from 'node:child_process'
3+
import process from 'node:process'
44
import { test } from 'node:test'
55

6-
console.log('Running tests...')
7-
86
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(/has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
12-
done()
13-
})
14-
})
15-
167
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) => {
189
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
1910
done()
2011
})
2112
})
2213

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(/request has been deprecated/.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(/request has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
24+
done()
25+
})
26+
}
27+
})
28+
2329
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(/node version/.test(stdout), 'Expected "node version" to be mentioned in output.')
30+
exec('node ./dist/cli.mjs current', (_error, stdout, stderr) => {
31+
assert.ok(/node version/.test(stdout) || /node version/.test(stderr), 'Expected "node version" to be mentioned in output.')
2632
done()
2733
})
2834
})
2935
})
3036

3137
test('global tests', async (t) => {
3238
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) => {
3440
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
3541
done()
3642
})
@@ -39,14 +45,14 @@ test('global tests', async (t) => {
3945

4046
test('package tests', async (t) => {
4147
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) => {
4349
assert.ok(/has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
4450
done()
4551
})
4652
})
4753

4854
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) => {
5056
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
5157
done()
5258
})
@@ -55,16 +61,16 @@ test('package tests', async (t) => {
5561

5662
test('config tests', async (t) => {
5763
await t.test('check config --list', (_t, done) => {
58-
exec('npm run dev config -- --list', (_error, stdout, _stderr) => {
59-
assert.ok(/latestVersion/.test(stdout), 'Expected "latestVersion" to be mentioned in config list.')
64+
exec('node ./dist/cli.mjs config -- --list', (_error, stdout, _stderr) => {
65+
assert.ok(/inspect and modify the config/.test(stdout), 'Expected "inspect and modify the config" to be mentioned in config list.')
6066
done()
6167
})
6268
})
6369
})
6470

6571
test('help tests', async (t) => {
6672
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) => {
6874
assert.ok(/display help for command/.test(stdout), 'Expected "display help for command" to be mentioned in help.')
6975
done()
7076
})

0 commit comments

Comments
 (0)