ant-design/tests/setupAfterEnv.ts
二货爱吃白萝卜 78cca16779
chore: default hashed (#37154)
* chore: default hashed

* test: try for clean default hashed

* chore: clean up

* chore: fix dist

* chore: es inject

* chore: no hashed in test env

* chore: update comment

* chore: hack in jest env

* chore: try unique entry
2022-08-19 17:45:03 +08:00

27 lines
734 B
TypeScript

import { toHaveNoViolations } from 'jest-axe';
import '@testing-library/jest-dom';
import { defaultConfig } from '../components/theme/index';
// Not use dynamic hashed for test env since version will change hash dynamically.
defaultConfig.hashed = false;
if (process.env.LIB_DIR === 'dist') {
jest.mock('../dist/antd', () => {
const antd = jest.requireActual('../dist/antd');
antd.theme.defaultConfig.hashed = false;
return antd;
});
} else if (process.env.LIB_DIR === 'es') {
jest.mock('../es/theme', () => {
const esTheme = jest.requireActual('../es/theme');
if (esTheme.defaultConfig) {
esTheme.defaultConfig.hashed = false;
}
return esTheme;
});
}
expect.extend(toHaveNoViolations);