Jest在Node环境下的测试配置
作者:互联网
安装依赖 package.json
"devDependencies": {
"@babel/core": "^7.18.2",
"@babel/preset-env": "^7.18.2",
"babel-jest": "^28.1.0",
"jest": "^28.1.0"
}
配置babel babel.config.js
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
};
测试脚本 os.spec.js
const MACOS_SYSTEM = 'Darwin'
const isMacOS = () => {
return require('os').type() === MACOS_SYSTEM
}
describe('os test', () => {
test('Is macOS system', () => {
expect(isMacOS()).toBeTruthy()
});
});
标签:Node,MACOS,const,Jest,jest,babel,7.18,测试,os 来源: https://www.cnblogs.com/ltfxy/p/16338022.html