Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"prettier/prettier": [
"error"
"error",
{
"trailingComma": "es5"
Copy link
Contributor

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?

Copy link
Contributor Author

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

}
],
"global-require": "off",
"max-len": [
Expand Down Expand Up @@ -73,7 +76,8 @@
{
"devDependencies": [
"**/*.stories.*",
"**/.storybook/**/*.*"
"**/.storybook/**/*.*",
"spec/**/*.*"
],
"peerDependencies": true
}
Expand All @@ -98,6 +102,7 @@
"*.config.js",
"lib/**/*.js",
"lib/**/*.d.ts",
"docs/**/*.js"
"docs/**/*.js",
"jest.setup.js"
]
}
25 changes: 25 additions & 0 deletions .github/workflows/run-test.yml
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
24 changes: 24 additions & 0 deletions jest.config.js
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' }],
},
},
]
};
12 changes: 12 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const failOnConsole = require('jest-fail-on-console')

class IntersectionObserver {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have failOnConsole on the Quizzes UI equivalent of this file. I don't think we have to have it but it might be useful?
https://github.com/Constructor-io/constructorio-ui-quizzes/blob/main/jest.setup.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
Loading