-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[zero][system] Add vitest and jest test runners
in vite app
- Loading branch information
1 parent
5a05279
commit 239d862
Showing
8 changed files
with
3,071 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-react", | ||
["@babel/preset-env", { "targets": { "node": "current" } }], | ||
"@babel/preset-typescript" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Mandatory to map so that the imports translate to cjs files | ||
// eslint-disable-next-line import/no-unresolved | ||
const { createTheme } = require('@mui/material/node/styles'); | ||
|
||
const theme = createTheme(); | ||
// @TODO - Make this part of the main package | ||
// @ts-ignore | ||
theme.applyDarkStyles = function applyDarkStyles(obj) { | ||
return { | ||
// @TODO - Use custom stylis plugin as in docs/src/createEmotionCache.ts | ||
// so that we don't need to use * | ||
'* :where([data-mui-color-scheme="dark"]) &': obj, | ||
}; | ||
}; | ||
|
||
/** | ||
* @type {import('jest').Config} | ||
*/ | ||
module.exports = { | ||
transform: { | ||
'\\.[jt]sx?': ['@mui/zero-jest', { theme }], | ||
}, | ||
// Mandatory to map so that the imports translate to cjs files | ||
moduleNameMapper: { | ||
'^@mui/material(.*)$': '@mui/material/node/$1', | ||
}, | ||
verbose: true, | ||
testEnvironment: 'jsdom', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-disable react/jsx-filename-extension */ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import Slider from './ZeroSlider'; | ||
|
||
describe('Slider', () => { | ||
it('should render', () => { | ||
const { container, rerender } = render(<Slider />); | ||
expect( | ||
container | ||
.getElementsByClassName('MuiSlider-root')[0] | ||
.classList.contains('MuiSlider-colorPrimary'), | ||
).toBeTruthy(); | ||
rerender(<Slider color="secondary" />); | ||
expect( | ||
container | ||
.getElementsByClassName('MuiSlider-root')[0] | ||
.classList.contains('MuiSlider-colorSecondary'), | ||
).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.