fz-react-cli
Version:
A CLI tool for build modern web application and libraries
53 lines (49 loc) • 1.61 kB
JavaScript
let fs = require('fs');
let path = require('path');
let appPath = fs.realpathSync(process.cwd());
let commonConfig = {
coverageReporters: ['json', 'html', 'json-summary', 'text'],
collectCoverage: true,
transform: {
'^.+\\.(js|jsx)$': path.resolve(__dirname, '..', 'jsPreprocessor.js'),
'^.+\\.css$': path.resolve(__dirname, '..', 'cssPreprocessor.js'),
'^(?!.*\\.(js|jsx|css|json)$)': path.resolve(
__dirname,
'..',
'otherFilesPreprocessor.js'
)
},
moduleFileExtensions: ['js'],
setupFiles: [
path.resolve(appPath, '__testUtils__', 'globals.js'),
path.resolve(__dirname, '..', 'setup.js')
],
globals: {
__DEVELOPMENT__: true,
__DOCS__: false,
__TEST__: true
}
};
module.exports = function(appFolder, forCommittedFiles = false) {
if (forCommittedFiles) {
return Object.assign({}, commonConfig, {
coverageDirectory: path.resolve(appPath, 'commitCoverage'),
testResultsProcessor: path.resolve(__dirname, '..', 'coverageResult.js')
});
}
return Object.assign({}, commonConfig, {
rootDir: appPath,
testPathIgnorePatterns: ['/node_modules/', 'docs'],
unmockedModulePathPatterns: ['__tests__', 'node_modules', '.*'],
testPathDirs: [`<rootDir>/${appFolder}/`],
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(jsx|js|json|node)$',
moduleNameMapper: {
'\\.(css|less)$': 'identity-obj-proxy'
},
testResultsProcessor: path.resolve(__dirname, '..', 'result.js'),
moduleDirectories: [
path.resolve(__dirname, '..', '..', 'node_modules'),
'node_modules'
]
});
};