-
Notifications
You must be signed in to change notification settings - Fork 4
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
chore: migrate from jest to vitest #518
base: main
Are you sure you want to change the base?
Changes from all commits
1db783c
589b54f
e25bab3
ccecbd8
682d150
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
/// <reference types="vitest" /> | ||
import { defineConfig } from 'vite'; | ||
import react from '@vitejs/plugin-react'; | ||
|
||
export default defineConfig({ | ||
plugins: [react()], | ||
test: { | ||
environment: 'jsdom', | ||
globals: true, | ||
setupFiles: './vitest.setup.mts', | ||
coverage: { | ||
provider: 'v8', | ||
}, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ | |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { TextEncoder, TextDecoder } from 'util'; | ||
import { afterEach } from 'vitest'; | ||
import { cleanup } from '@testing-library/react'; | ||
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. there was already a PR to add @testing-library/react https://github.com/gridsuite/commons-ui/pull/216/files?w=1 it simplifies the code we should use it if we add testing-library |
||
|
||
// fix for ReferenceError: TextDecoder / TextEncoder is not defined | ||
Object.assign(global, { TextDecoder, TextEncoder }); | ||
// runs a clean after each test case (e.g. clearing jsdom) | ||
afterEach(() => { | ||
cleanup(); | ||
}); |
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.
do we really need to redefine a vitestconfig file ?
"f you are using Vite and have a vite.config file, Vitest will read it to match with the plugins and setup as your Vite app. If you want to have a different configuration for testing [...] you could [...] create vitest.config.ts"
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.
on other project, we set this directly on vite.config file with those parameters
test: { globals: true, environment: 'jsdom', setupFiles: './src/testSetup.ts', },
and the setup file, define a default config, like after
afterEach(() => { cleanup() });