Skip to content

Commit 4627a18

Browse files
create seperate test for old node versions to support Jest 30
1 parent fb56c2a commit 4627a18

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

.github/workflows/node-compatibility.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
node-version: [16.6.0, 16.x, 17.0.0, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x, 23.x, 24.x]
16+
node-version: [18.x, 19.x, 20.x, 21.x, 22.x, 23.x, 24.x]
1717

1818
steps:
1919
- name: Checkout
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Node.js Compatibility
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
node:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
node-version: [16.6.0, 16.x, 17.0.0, 17.x]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup node ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
check-latest: true
27+
28+
- name: Install packages
29+
run: npm ci
30+
31+
- name: Run tests
32+
run: npx ts-node tests/old-node.ts
33+
34+
- name: Upload mysqlmsn directory
35+
if: ${{ failure() }}
36+
uses: actions/[email protected]
37+
with:
38+
name: node-${{ matrix.node-version }}
39+
path: /tmp/mysqlmsn
40+
compression-level: 9

tests/old-node.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createDB } from '../src/index'
2+
import sql from 'mysql2/promise'
3+
4+
async function main() {
5+
console.log('Starting test...')
6+
const db = await createDB()
7+
8+
const connection = await sql.createConnection({
9+
host: '127.0.0.1',
10+
user: db.username,
11+
port: db.port
12+
})
13+
14+
const received = await connection.query('SELECT 1 + 1')
15+
const result = Object.values(received[0][0])[0]
16+
if (result !== 2) {
17+
throw `Result is not what was expected. Expected 2, received ${result}`
18+
}
19+
20+
await connection.end()
21+
await db.stop()
22+
console.log('Test was successful.')
23+
24+
}
25+
26+
main()

0 commit comments

Comments
 (0)