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

Add support for Jest #4

Merged
merged 10 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,20 @@ jobs:
run: npm run build
- name: Test
run: npm run test:mocha

test-jest:
runs-on: ubuntu-latest
strategy:
matrix:
jest: ['28.0', '29.0']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install Packages
run: npm ci
- run: npm i jest@${{ matrix.jest }}
- run: npx jest --version
- name: Build
run: npm run build
- name: Test
run: npm run test:jest
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ npm install --save-dev eslint-snapshot-rule-tester
> **Requirements**
> - ESLint v8.4.0 or above
> - Node.js v18.x or above
> - Mocha v6.0.0 or above
> - Mocha v6.0.0 or above OR Jest v28.0.0 or above

## Usage

Expand Down Expand Up @@ -57,12 +57,13 @@ Output:
---
```

For the full example, see the [test file here](https://github.com/RunDevelopment/eslint-snapshot-rule-tester/blob/main/tests/mocha/no-strings.ts) and [snapshot file here](https://github.com/RunDevelopment/eslint-snapshot-rule-tester/blob/main/tests/mocha/__snapshots__/no-strings.ts.snap).
For the full example, see the [test file here](https://github.com/RunDevelopment/eslint-snapshot-rule-tester/blob/main/tests/mocha/no-strings.ts) and [snapshot file here](https://github.com/RunDevelopment/eslint-snapshot-rule-tester/blob/main/tests/mocha/__snapshots__/no-strings.ts.eslintsnap).

### Updating snapshots

To update snapshots, run the tests with the `--update` flag:
To update snapshots, run the tests with the `--update` or `-u` flag:

```sh
mocha tests/**/*.js --update
jest -u
```
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};