Skip to content

Commit 747e914

Browse files
committed
Setup jest testing environment
1 parent 88205d4 commit 747e914

File tree

8 files changed

+1303
-82
lines changed

8 files changed

+1303
-82
lines changed

.eslintrc.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
"no-unused-vars": "off",
3232
"@typescript-eslint/no-unused-vars": "warn",
3333
"prettier/prettier": [
34-
"error"
34+
"error",
35+
{
36+
"trailingComma": "es5"
37+
}
3538
],
3639
"global-require": "off",
3740
"max-len": [
@@ -73,7 +76,8 @@
7376
{
7477
"devDependencies": [
7578
"**/*.stories.*",
76-
"**/.storybook/**/*.*"
79+
"**/.storybook/**/*.*",
80+
"spec/**/*.*"
7781
],
7882
"peerDependencies": true
7983
}
@@ -98,6 +102,7 @@
98102
"*.config.js",
99103
"lib/**/*.js",
100104
"lib/**/*.d.ts",
101-
"docs/**/*.js"
105+
"docs/**/*.js",
106+
"jest.setup.js"
102107
]
103108
}

.github/workflows/run-test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Run tests
2+
on:
3+
pull_request:
4+
branches:
5+
- "**"
6+
concurrency:
7+
group: run-tests-${{ github.head_ref }}
8+
cancel-in-progress: true
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node: ["18.13.0"]
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v2
18+
- name: Set up node
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node }}
22+
- name: Install dependencies
23+
run: npm install
24+
- name: Run tests
25+
run: npm run test

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// jest.config.js
2+
module.exports = {
3+
projects: [
4+
{
5+
displayName: 'client',
6+
testEnvironment: 'jsdom',
7+
testMatch: ['**/**/*.test.(js|jsx)', '!**/**/*.server.test.(js|jsx)'],
8+
setupFiles: ['./jest.setup.js'],
9+
},
10+
{
11+
displayName: 'server',
12+
testEnvironment: 'node',
13+
testMatch: ['**/**/*.server.test.(js|jsx)'],
14+
},
15+
]
16+
};

jest.setup.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class IntersectionObserver {
2+
constructor() {}
3+
observe() {}
4+
unobserve() {}
5+
disconnect() {}
6+
}
7+
8+
global.IntersectionObserver = IntersectionObserver;

0 commit comments

Comments
 (0)