Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest to vitest #10420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,21 @@ jobs:
uses: ./.github/actions/build-fabric-cached
- name: Run ${{ matrix.suite }} tests
run: npm run test -- -c node -s ${{ matrix.suite }}
jest:
name: Jest tests
vitest:
name: Vitest tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/cached-install
with:
node-version: 20.x
install-system-deps: false
- name: Run Jest unit test
run: npm run test:jest:coverage
- name: Run Vitest unit test
run: npm run test:vitest:coverage
- name: Upload test coverage
uses: actions/upload-artifact@v4
with:
name: coverage-jest
name: coverage-vitest
path: ./.nyc_output/*.json
include-hidden-files: true

Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
path: ./.nyc_output
- uses: actions/download-artifact@v4
with:
name: coverage-jest
name: coverage-vitest
path: ./.nyc_output
- uses: actions/download-artifact@v4
with:
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ It is more than likely you will be requested to change stuff and refine your wor
[![🧪](../../actions/workflows/tests.yml/badge.svg)](../../actions/workflows/tests.yml)
[![CodeQL](../../actions/workflows/codeql-analysis.yml/badge.svg)](../../actions/workflows/codeql-analysis.yml)

| Suite | unit (node) | e2e (browser) |
| ------------------------------------------------------------------------------------------------------------- | :--------------------------------------------- | :----------------------------------------------------------------------------------- |
| Framework | [`jest`][jest] | [`playwright`][playwright] |
| Setup | | <pre>npm run build -- -f -w</pre> |
| Running Tests<br><br><pre>\<test cmd\> -- [filter] [watch]</pre><br>It is advised to use filters to save time | <pre>npm run test:jest -- [filters] [-w]</pre> | <pre>npm run test:e2e -- [filters] [--ui]</pre> |
| Writing Tests | Add/update `src/*.(spec\|test).ts` files | - Update tests in `e2e/tests`<br>- Create a new test based on `e2e/template` |
| Test Gen | | <pre>npm start vanilla<br>npx playwright codegen http://localhost:1234</pre> |
| Test Spec | | - `index.ts`: built and loaded into the web app<br> - `index.spec.ts`: test spec<br> |
| Outputs | Snapshots next to the test file | - Snapshots next to the test file <br>- `e2e/test-report`<br>- `e2e/test-results` |
| Suite | unit (node) | e2e (browser) |
| ------------------------------------------------------------------------------------------------------------- | :----------------------------------------------- | :----------------------------------------------------------------------------------- |
| Framework | [`vitest`][vitest] | [`playwright`][playwright] |
| Setup | | <pre>npm run build -- -f -w</pre> |
| Running Tests<br><br><pre>\<test cmd\> -- [filter] [watch]</pre><br>It is advised to use filters to save time | <pre>npm run test:vitest -- [filters] [-w]</pre> | <pre>npm run test:e2e -- [filters] [--ui]</pre> |
| Writing Tests | Add/update `src/*.(spec\|test).ts` files | - Update tests in `e2e/tests`<br>- Create a new test based on `e2e/template` |
| Test Gen | | <pre>npm start vanilla<br>npx playwright codegen http://localhost:1234</pre> |
| Test Spec | | - `index.ts`: built and loaded into the web app<br> - `index.spec.ts`: test spec<br> |
| Outputs | Snapshots next to the test file | - Snapshots next to the test file <br>- `e2e/test-report`<br>- `e2e/test-results` |

### Legacy Test Suite

Expand Down Expand Up @@ -266,7 +266,7 @@ Don't forget to unlink the package once you're done.
[jsdoc]: https://jsdoc.app/
[tsjsdoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
[playwright]: https://playwright.dev/
[jest]: https://jestjs.io/
[vitest]: https://vitest.dev/
[qunit]: https://qunitjs.com/
[testem]: https://github.com/testem/testem
[unit_test]: https://github.com/fabricjs/fabric.js/blob/93dd2dcca705a4b481fbc9982da4952ef5b4ed1d/test/unit/point.js#L227-L237
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default [
console: 'readonly',
},
parserOptions: {
project: true,
project: 'tsconfig.spec.json',
tsconfigRootDir: './',
},
},
Expand Down
2 changes: 1 addition & 1 deletion fabric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export { loadSVGFromString } from './src/parser/loadSVGFromString';
export { loadSVGFromURL } from './src/parser/loadSVGFromURL';
export { parseSVGDocument } from './src/parser/parseSVGDocument';

// todo convert tests to jest and stop exporting those.
// todo convert tests to vitest and stop exporting those.
export { parseAttributes } from './src/parser/parseAttributes';
export { parseStyleAttribute } from './src/parser/parseStyleAttribute';
export { parsePointsAttribute } from './src/parser/parsePointsAttribute';
Expand Down
195 changes: 0 additions & 195 deletions jest.config.js

This file was deleted.

9 changes: 0 additions & 9 deletions jest.resolver.js

This file was deleted.

Loading
Loading