Skip to content

Commit

Permalink
test(event-handler): migrate to vitest (#3126)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamorosi authored Sep 27, 2024
1 parent 6d4b3de commit 39c8608
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ jobs:
"packages/batch",
"packages/commons",
"packages/jmespath",
"packages/idempotency"
"packages/idempotency",
"packages/event-handler"
]
fail-fast: false
steps:
Expand Down Expand Up @@ -91,16 +92,14 @@ jobs:
-w packages/tracer \
-w packages/metrics \
-w packages/parameters \
-w packages/parser \
-w packages/event-handler
-w packages/parser
- name: Run unit tests
run: |
npm t -w packages/logger \
-w packages/tracer \
-w packages/metrics \
-w packages/parameters \
-w packages/parser \
-w packages/event-handler
-w packages/parser
check-examples:
runs-on: ubuntu-latest
env:
Expand Down
3 changes: 1 addition & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ npm t \
-w packages/metrics \
-w packages/tracer \
-w packages/parameters \
-w packages/parser \
-w packages/event-handler
-w packages/parser

npx vitest --run --coverage --changed="$(git merge-base HEAD main)"
29 changes: 0 additions & 29 deletions packages/event-handler/jest.config.cjs

This file was deleted.

6 changes: 4 additions & 2 deletions packages/event-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
},
"private": true,
"scripts": {
"test": "npm run test:unit",
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
"test": "vitest --run",
"test:unit": "vitest --run",
"test:unit:coverage": "vitest --run tests/unit --coverage.enabled --coverage.thresholds.100 --coverage.include='src/**'",
"test:unit:types": "echo 'Not Implemented'",
"test:e2e:nodejs18x": "echo \"Not implemented\"",
"test:e2e:nodejs20x": "echo \"Not implemented\"",
"test:e2e": "echo \"Not implemented\"",
Expand Down
4 changes: 2 additions & 2 deletions packages/event-handler/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"rootDir": "../../",
"noEmit": true
},
"include": ["../src/**/*", "./**/*"]
"include": ["../../testing/src/setupEnv.ts", "../src/**/*", "./**/*"]
}
10 changes: 3 additions & 7 deletions packages/event-handler/tests/unit/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/**
* Test Event Handler
*
* @group unit/event-handler
*/
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { foo } from '../../src/index.js';

describe('Event Handler', () => {
const ENVIRONMENT_VARIABLES = process.env;

beforeEach(() => {
jest.clearAllMocks();
jest.resetModules();
vi.clearAllMocks();
vi.resetModules();
process.env = { ...ENVIRONMENT_VARIABLES };
});

Expand Down
8 changes: 8 additions & 0 deletions packages/event-handler/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineProject } from 'vitest/config';

export default defineProject({
test: {
environment: 'node',
setupFiles: ['../testing/src/setupEnv.ts'],
},
});
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
...coverageConfigDefaults.exclude,
'packages/batch/src/types.ts',
'packages/commons/src/types/**',
'packages/event-handler/**',
'packages/event-handler/src/types/**',
'packages/idempotency/src/types/**',
'packages/jmespath/src/types.ts',
'packages/logger/**',
Expand Down

0 comments on commit 39c8608

Please sign in to comment.