Skip to content

Commit

Permalink
test: fix typescript testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKreil committed Nov 23, 2023
1 parent 9082556 commit 516ae4d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: npm audit

- name: Run tests
run: npm run test-node
run: npm run test

- name: Generate test coverage
run: npm run test-coverage
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci

- name: Run tests
run: npm run test

- name: Build styles
run: npm run build-styles

Expand Down
14 changes: 14 additions & 0 deletions jest.config.typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Config } from 'jest';

const config: Config = {
testEnvironment: 'node',
transform: {
'^.+\\.ts$': ['ts-jest', { tsconfig: 'tsconfig.node.json', useESM: true }]
},
testRegex: 'src/.*\\.test\\.ts',
extensionsToTreatAsEsm: ['.ts'],
collectCoverage: false,
resolver: 'jest-ts-webcompat-resolver',
}

export default config;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"doc": "vrt ts2md src/index.ts tsconfig.node.json | vrt insertmd README.md '### Node.js API'",
"lint": "eslint --color .",
"release": "tsx scripts/release.ts",
"test": "npm run test-node && npm run test-coverage && npm run test-browser",
"test": "npm run test-typescript && npm run test-node && npm run test-browser",
"test-browser": "npm run build-browser && echo 'add browser test'",
"test-coverage": "NODE_OPTIONS=--experimental-vm-modules jest -c=jest.config.coverage.ts",
"test-node": "npm run build-node && NODE_OPTIONS=--experimental-vm-modules jest -c=jest.config.node.ts",
"test-typescript": "NODE_OPTIONS=--experimental-vm-modules jest -c=jest.config.typescript.ts",
"upgrade": "npm-check-updates -u && rm -f package-lock.json && rm -rf node_modules; npm i"
},
"repository": {
Expand Down

0 comments on commit 516ae4d

Please sign in to comment.