Skip to content

Commit f8cc6ca

Browse files
authored
Merge pull request #1029 from supertokens/feat/unit-testing-23-1
ci: unit testing [23.1]
2 parents c57b9dd + 79f3ca2 commit f8cc6ca

File tree

125 files changed

+1760
-2447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1760
-2447
lines changed

.github/workflows/unit-test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: "Unit Tests"
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- labeled
10+
- unlabeled
11+
push:
12+
branches:
13+
- "[0-9]+.[0-9]+"
14+
15+
# Only one instance of this workflow will run on the same ref (PR/Branch/Tag)
16+
# Previous runs will be cancelled.
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
define-versions:
23+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests')
24+
runs-on: ubuntu-latest
25+
outputs:
26+
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
27+
cdiVersions: ${{ steps.versions.outputs.cdiVersions }}
28+
nodeVersions: '["18.20", "20.19", "22.14"]'
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: supertokens/get-supported-versions-action@main
32+
id: versions
33+
with:
34+
has-fdi: true
35+
has-cdi: true
36+
37+
test:
38+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests')
39+
runs-on: ubuntu-latest
40+
needs: define-versions
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
node-version: ${{ fromJSON(needs.define-versions.outputs.nodeVersions) }}
45+
cdi-version: ${{ fromJSON(needs.define-versions.outputs.cdiVersions) }}
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: supertokens/get-versions-action@main
49+
id: versions
50+
with:
51+
driver-name: node
52+
cdi-version: ${{ matrix.cdi-version }}
53+
env:
54+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
55+
- uses: actions/setup-node@v4
56+
with:
57+
node-version: ${{ matrix.node-version }}
58+
- name: Install dependencies
59+
run: |
60+
npm install
61+
- name: Run unit tests
62+
run: |
63+
docker compose up --wait
64+
npm run test
65+
docker compose down
66+
env:
67+
SUPERTOKENS_CORE_VERSION: ${{ steps.versions.outputs.coreVersionXy }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ releasePassword
1515
/temp_*
1616
/.nyc_output
1717
.circleci/.pat
18+
test-results*

.mocharc.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@ spec: test/**/*.test.*
22
extension: [ts, js]
33
exit: true
44
slow: 10000
5-
timeout: 20000
6-
reporter: spec
5+
timeout: 40000
6+
reporter: mocha-multi-reporters
7+
require: test/hooks.js
8+
reporter-option:
9+
- configFile=mocha-multi-reporters.json

lib/build/recipe/oauth2provider/constants.js

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/session/constants.js

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocha-multi-reporters.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"reporterEnabled": "spec, mocha-junit-reporter, mocha-json-output-reporter",
3+
"mochaJunitReporterReporterOptions": {
4+
"mochaFile": "test-results.xml"
5+
},
6+
"mochaJsonOutputReporterReporterOptions": {
7+
"output": "test-results.json"
8+
}
9+
}

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "NodeJS driver for SuperTokens core",
55
"main": "index.js",
66
"scripts": {
7-
"test": "TEST_MODE=testing npx ts-mocha -p lib/tsconfig.json -n loader=ts-node/esm --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --timeout 500000",
7+
"test": "TEST_MODE=testing npx ts-mocha -p lib/tsconfig.json -n loader=ts-node/esm --node-option no-experimental-fetch -r test/fetch-polyfill.mjs",
88
"test-exports": "./test/testExports.sh",
99
"build-check": "cd lib && npx tsc -p tsconfig.json --noEmit && cd ../test/with-typescript && npm run build",
1010
"build": "cd lib && rm -rf build && npx tsc -p tsconfig.json && cd ../test/with-typescript && npm run build && cd ../.. && npm run post-build",
@@ -137,7 +137,7 @@
137137
"pako": "^2.1.0",
138138
"pkce-challenge": "^3.0.0",
139139
"process": "^0.11.10",
140-
"set-cookie-parser": "^2.6.0",
140+
"set-cookie-parser": "^2.7.1",
141141
"supertokens-js-override": "^0.0.4",
142142
"tldts": "^6.1.48",
143143
"twilio": "^4.19.3"
@@ -173,8 +173,11 @@
173173
"loopback-datasource-juggler": "^4.26.0",
174174
"mocha": "^10.2.0",
175175
"mocha-split-tests": "github:rishabhpoddar/mocha-split-tests",
176+
"mocha-json-output-reporter": "^2.1.0",
177+
"mocha-junit-reporter": "^2.2.1",
178+
"mocha-multi-reporters": "^1.5.1",
176179
"next": "^14.0.4",
177-
"next-test-api-route-handler": "^3.1.10",
180+
"next-test-api-route-handler": "^4.0.16",
178181
"nock": "11.7.0",
179182
"node-fetch": "^3.3.2",
180183
"nyc": "^15.1.0",

0 commit comments

Comments
 (0)