Skip to content

Commit c6fb937

Browse files
authored
Add test for worker environment (#1092)
1 parent fbc1e31 commit c6fb937

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

jest.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ module.exports = {
66
testEnvironment: 'node',
77
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
88
roots: ['<rootDir>/src'],
9-
setupFiles: ['./setup-jest.ts'],
9+
setupFilesAfterEnv: ['./setup-jest.ts'],
1010
transform: {
1111
'^.+\\.ts?$': 'ts-jest',
1212
},
13+
moduleNameMapper: {
14+
'^jose': require.resolve('jose'),
15+
},
1316
};

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"lint": "tslint -p tsconfig.json -c tslint.json",
3333
"test": "jest",
3434
"test:watch": "jest --watch",
35+
"test:worker": "jest src/worker.spec.ts",
3536
"prettier": "prettier \"src/**/*.{js,ts,tsx}\" --check",
3637
"format": "prettier \"src/**/*.{js,ts,tsx}\" --write",
3738
"prepublishOnly": "yarn run build"
@@ -47,6 +48,7 @@
4748
"@types/node": "14.18.54",
4849
"@types/pluralize": "0.0.30",
4950
"jest": "29.6.2",
51+
"jest-environment-miniflare": "^2.14.2",
5052
"jest-fetch-mock": "^3.0.3",
5153
"prettier": "2.8.8",
5254
"supertest": "6.3.3",
@@ -65,5 +67,4 @@
6567
"default": "./lib/index.js"
6668
}
6769
}
68-
}
69-
70+
}

src/worker.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @jest-environment miniflare
3+
*/
4+
5+
import { WorkOS } from './index.worker';
6+
7+
test('WorkOS is initialized without errors', () => {
8+
expect(() => new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU')).not.toThrow();
9+
});

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"declaration": true,
1515
"outDir": "lib",
1616
"strict": true,
17-
"lib": ["dom", "es2019"]
17+
"lib": ["dom", "es2019"],
18+
"types": ["jest", "jest-environment-miniflare/globals"]
1819
},
1920
"include": ["src"]
2021
}

0 commit comments

Comments
 (0)