mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(cli): support custom jest config
This commit is contained in:
parent
904b53c368
commit
99a8ff7b6b
@ -1,10 +1,13 @@
|
|||||||
|
import { join } from 'path';
|
||||||
|
import { existsSync } from 'fs-extra';
|
||||||
import {
|
import {
|
||||||
|
ROOT,
|
||||||
JEST_INIT_FILE,
|
JEST_INIT_FILE,
|
||||||
JEST_FILE_MOCK_FILE,
|
JEST_FILE_MOCK_FILE,
|
||||||
JEST_STYLE_MOCK_FILE
|
JEST_STYLE_MOCK_FILE
|
||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
|
|
||||||
module.exports = {
|
const DEFAULT_CONFIG = {
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
|
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
|
||||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE
|
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE
|
||||||
@ -26,3 +29,18 @@ module.exports = {
|
|||||||
coverageReporters: ['html', 'lcov', 'text-summary'],
|
coverageReporters: ['html', 'lcov', 'text-summary'],
|
||||||
coverageDirectory: './test/coverage'
|
coverageDirectory: './test/coverage'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function readRootConfig() {
|
||||||
|
const ROOT_CONFIG_PATH = join(ROOT, 'jest.config.js');
|
||||||
|
|
||||||
|
if (existsSync(ROOT_CONFIG_PATH)) {
|
||||||
|
return require(ROOT_CONFIG_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
...DEFAULT_CONFIG,
|
||||||
|
...readRootConfig()
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user