fz-react-cli
Version:
A CLI tool for build modern web application and libraries
47 lines (42 loc) • 1.7 kB
JavaScript
;
var fs = require('fs');
var path = require('path');
var appPath = fs.realpathSync(process.cwd());
var commonConfig = {
coverageReporters: ['json', 'html', 'json-summary', 'text'],
collectCoverage: true,
moduleDirectories: [path.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
transform: {
'^.+\\.(js|jsx)$': path.resolve(__dirname, '..', 'jsPreprocessor.js'),
'^.+\\.css$': path.resolve(__dirname, '..', 'cssPreprocessor.js'),
'^(?!.*\\.(js|jsx|css|json)$)': path.resolve(__dirname, '..', 'otherFilesPreprocessor.js')
},
transformIgnorePatterns: ['/node_modules.*?.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) {
var forCommittedFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 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')
});
};