Skip to content

Commit

Permalink
refactor(tests): migrate to vitest, move all tests to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
elbotho committed Jan 10, 2025
1 parent 1ceb88a commit 870b8ef
Show file tree
Hide file tree
Showing 224 changed files with 385 additions and 2,177 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/web_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ jobs:
- run: yarn
- run: yarn lint:tsc

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn
- run: yarn test

editor-test:
runs-on: ubuntu-latest
steps:
Expand All @@ -52,4 +42,4 @@ jobs:
with:
node-version: 20
- run: yarn
- run: yarn editor:test
- run: yarn test
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/abab-npm-2.0.6-2662fba7f0-6ffc1af4ff.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/co-npm-4.6.0-03f2d1feb6-5210d92230.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/ejs-npm-3.1.10-4e8cf4bdc1-ce90637e9c.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/exit-npm-0.1.2-ef3761a67d-abc407f07a.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/psl-npm-1.9.0-a546edad1a-20c4277f64.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/tmpl-npm-1.0.5-d399ba37e2-cd922d9b85.zip
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/tr46-npm-3.0.0-e1ae1ea7c9-44c3cc6767.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Creates a build of the frontend, shows summary of build artefacts and creates in
yarn test
```

Runs jest tests.
Runs editor unit tests (vitest).

```
yarn codegen
Expand Down
17 changes: 0 additions & 17 deletions apps/web/jest.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions apps/web/jest.setup.ts

This file was deleted.

5 changes: 1 addition & 4 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"lint:prettier": "yarn _prettier --check",
"lint:tsc": "tsc --noEmit",
"show-unused-exports": "ts-unused-exports tsconfig.json --excludePathsFromReport=src/pages/ --excludePathsFromReport=src/fetcher/graphql-types/operations.ts --allowUnusedTypes",
"start": "next start",
"test": "jest"
"start": "next start"
},
"resolutions": {
"@serlo/katex-styles": "1.0.1"
Expand Down Expand Up @@ -100,7 +99,6 @@
"@tailwindcss/typography": "^0.5.15",
"@types/canvas-confetti": "^1.6.4",
"@types/iframe-resizer": "^3.5.13",
"@types/jest": "^29.5.14",
"@types/js-cookie": "^3.0.6",
"@types/json-diff": "^1.0.3",
"@types/katex": "^0.16.7",
Expand All @@ -123,7 +121,6 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"graphql-tag": "2.12.6",
"jest": "^29.7.0",
"micromark": "^4.0.1",
"npm-run-all": "^4.1.5",
"postcss-flexbugs-fixes": "^5.0.2",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"editor:build": "yarn workspace @serlo/editor build",
"editor:publish": "yarn workspace @serlo/editor run publish:package",
"editor:publish-local": "yarn workspace @serlo/editor yalc:publish",
"editor:test": "yarn workspace @serlo/editor test",
"format": "yarn workspace @serlo/frontend format",
"format:eslint": "yarn workspace @serlo/frontend format:eslint",
"format:prettier": "yarn workspaces foreach -Ap run format:prettier",
Expand All @@ -44,7 +43,7 @@
"lint:prettier": "cross-env FORCE_COLOR=true yarn workspaces foreach -Aip run lint:prettier",
"lint:tsc": "yarn workspace @serlo/frontend lint:tsc",
"start": "yarn workspace @serlo/frontend start",
"test": "yarn workspace @serlo/frontend test"
"test": "yarn workspace @serlo/editor test"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getMatchingAnswer } from '@editor/plugins/input-exercise/helper/get-matching-answer'
import { InputExerciseType } from '@editor/plugins/input-exercise/input-exercise-type'
import { evaluate } from 'mathjs'
import { expect, test, describe } from 'vitest'

const answers = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getMatchingAnswer } from '@editor/plugins/input-exercise/helper/get-matching-answer'
import { InputExerciseType } from '@editor/plugins/input-exercise/input-exercise-type'
import { evaluate } from 'mathjs'
import { expect, test, describe } from 'vitest'

const answers = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getMatchingAnswer } from '@editor/plugins/input-exercise/helper/get-matching-answer'
import { InputExerciseType } from '@editor/plugins/input-exercise/input-exercise-type'
import { evaluate } from 'mathjs'
import { expect, test, describe } from 'vitest'

const answers = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { migrate } from '@editor/package/storage-format'
import { expect, test } from 'vitest'

test('A document not being in the storage format can be migrated', () => {
const { stateChanged, migratedState } = migrate({ plugin: 'rows' }, 'unknown')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isEmptyCustomText, isEmptyDescendant } from '@editor/package'
import { expect, test, describe } from 'vitest'

const text = { text: 'abc123' }
const emptyText = { text: '' }
Expand Down
13 changes: 0 additions & 13 deletions packages/editor/jest.config.mjs

This file was deleted.

8 changes: 3 additions & 5 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"lint:eslint": "yarn _eslint",
"lint:prettier": "yarn _prettier --check",
"lint:tsc": "tsc --noEmit",
"test": "jest",
"test": "vitest run",
"publish:package": "npm publish",
"yalc:publish": "yarn build && yalc publish --push --sig"
},
Expand Down Expand Up @@ -95,8 +95,6 @@
"fp-ts": "^2.16.9",
"io-ts": "^2.2.21",
"is-hotkey": "0.2.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"katex": "^0.16.11",
"mathjs": "^13.2.2",
"npm-run-all": "^4.1.5",
Expand Down Expand Up @@ -124,13 +122,13 @@
"slate-react": "0.111.0",
"tailwindcss": "^3.4.15",
"ts-debounce": "^4.0.0",
"ts-jest": "^29.2.5",
"ts-key-enum": "^2.0.13",
"typescript": "^5.6.3",
"uuid": "^11.0.3",
"vite": "^5.4.11",
"vite-plugin-dts": "4.3.0",
"vite-plugin-svgr": "^4.3.0"
"vite-plugin-svgr": "^4.3.0",
"vitest": "^2.1.8"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-config/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = {
},
env: {
node: true,
jest: true, //!
},
plugins: ['@typescript-eslint', 'import', 'react-hooks'],
settings: {
Expand All @@ -40,7 +39,6 @@ module.exports = {
'node_modules/',
'tailwind.config.js',
'next.config.js',
'jest.config.js',
'prettier.config.js',
],
overrides: [
Expand Down
Loading

0 comments on commit 870b8ef

Please sign in to comment.