-
Notifications
You must be signed in to change notification settings - Fork 3
Setup jest testing environment #146
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Run tests | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - "**" | ||
| concurrency: | ||
| group: run-tests-${{ github.head_ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node: ["18.13.0"] | ||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v2 | ||
| - name: Set up node | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: ${{ matrix.node }} | ||
| - name: Install dependencies | ||
| run: npm install | ||
| - name: Run tests | ||
| run: npm run test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // jest.config.js | ||
| module.exports = { | ||
| projects: [ | ||
| { | ||
| displayName: 'client', | ||
| testEnvironment: 'jsdom', | ||
| testMatch: ['**/**/*.test.(js|jsx|ts|tsx)', '!**/**/*.server.test.(js|jsx|ts|tsx)'], | ||
| setupFilesAfterEnv: ['./jest.setup.js', 'jest-fail-on-console'], // Ensures setup jest.setup.js scripts run after jest is fully setup | ||
| moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
| transform: { | ||
| '^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }], | ||
| }, | ||
| }, | ||
| { | ||
| displayName: 'server', | ||
| testEnvironment: 'node', | ||
| testMatch: ['**/**/*.server.test.(js|jsx|ts|tsx)'], | ||
| moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
| transform: { | ||
| '^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }], | ||
| }, | ||
| }, | ||
| ] | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| const failOnConsole = require('jest-fail-on-console') | ||
|
|
||
| class IntersectionObserver { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you I didn't know I needed this but it will make testing easier for the other PR. Adding it |
||
| constructor() {} | ||
| observe() {} | ||
| unobserve() {} | ||
| disconnect() {} | ||
| } | ||
|
|
||
| failOnConsole() | ||
|
|
||
| global.IntersectionObserver = IntersectionObserver; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linting used to fail but it's not anymore. Removing it