Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeininger committed Nov 28, 2023
1 parent b3ad825 commit f81a377
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 25 deletions.
15 changes: 8 additions & 7 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
env:
browser: true
es6: true
jest/globals: true
vitest-globals/env: true
extends:
- 'eslint:recommended'
- 'plugin:react/recommended'
- 'plugin:react/jsx-runtime'
- 'plugin:vitest-globals/recommended'
globals:
global: false
module: false
Expand Down Expand Up @@ -265,15 +266,15 @@ rules:
- error
- never
react/jsx-uses-react: error
jest/no-disabled-tests: warn
jest/no-focused-tests: error
jest/no-identical-title: error
jest/prefer-to-have-length: warn
jest/valid-expect: error
vitest/no-disabled-tests: warn
vitest/no-focused-tests: error
vitest/no-identical-title: error
vitest/prefer-to-have-length: warn
vitest/valid-expect: error
plugins:
- react
- vitest
- simple-import-sort
- jest
settings:
react:
version: detect
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
with:
name: Frontend
token: ${{ secrets.CODECOV_TOKEN }}
files: .jest-coverage/clover.xml
files: coverage/clover.xml
flags: frontend
fail_ci_if_error: true
verbose: true
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ node_modules/.timestamp: package.json

oereb_client/static/build/.timestamp: node_modules/.timestamp vite.config.js $(SRC_JS) $(SRC_SCSS)
rm -rf oereb_client/static/build/
NODE_ENV=production ./node_modules/.bin/vite build
./node_modules/.bin/vite build
touch $@


Expand Down Expand Up @@ -100,7 +100,7 @@ lint-js-fix: node_modules/.timestamp .eslintrc.yml $(SRC_JS) $(TEST_JS)

.PHONY: test-js
test-js: $(SRC_JS) $(TEST_JS)
NODE_ENV=test ./node_modules/.bin/vitest --coverage --run
./node_modules/.bin/vitest --coverage --run

.PHONY: check-js
check-js: git-attributes lint-js test-js
Expand All @@ -123,7 +123,7 @@ serve: build app.ini

.PHONY: serve-dev
serve-dev: build app.ini node_modules/.timestamp .venv/.requirements.timestamp
NODE_ENV=production ./node_modules/.bin/vite build --watch &
./node_modules/.bin/vite build --watch &
.venv/bin/pserve app.ini --reload

.PHONY: serve-devwin
Expand Down
196 changes: 186 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-storybook": "^0.6.15",
"eslint-plugin-vitest": "^0.3.10",
"eslint-plugin-vitest-globals": "^1.4.0",
"file-loader": "^6.2.0",
"file-saver": "^2.0.5",
"glob-parent": "^6.0.2",
Expand Down
4 changes: 2 additions & 2 deletions test/js/component/topic/__snapshots__/topic.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ exports[`topic component > should render topic 2`] = `
</button>
</h2>
<div
class="accordion-collapse collapsing"
style="height: 0px;"
class="accordion-collapse collapse show"
style=""
>
<div
class="accordion-body"
Expand Down
4 changes: 2 additions & 2 deletions test/js/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import '@testing-library/jest-dom/vitest';

import createFetchMock from "vitest-fetch-mock";
import {initReactI18next} from "react-i18next";
import ResizeObserver from "resize-observer-polyfill";
import { vi } from "vitest";
import {vi} from "vitest";
import createFetchMock from "vitest-fetch-mock";

import i18n from '../../oereb_client/static/src/i18n';

Expand Down
4 changes: 4 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default defineConfig({
react(),
htmlPurge()
],
define: {
// 'process.env.NODE_ENV': '"production"'
'process.env': {}
},
test: {
environment: 'jsdom',
globals: true,
Expand Down

0 comments on commit f81a377

Please sign in to comment.