我必须使用一些继承的代码创建一些单元测试。
所有代码都在一个大文件中,最终需要将其分开。
我的karma-jasmine
单元测试提取了一个引用chilkat_node8_win32
的大文件。我的测试用例没有执行chilkat
。我似乎无法从chilkat
中排除karma.config.js
。 chilkat
在代码内,而不是单独的文件。
我已经在操作上设置并成功测试了世界karma
单元测试。然后,我开始测试目标代码,并遇到各种配置错误。我要看最后一个了。
环顾四周...我找不到与karma
相关的任何chilkat
相关单元测试,这并不是python
中的死链接,也不是给我的防病毒软件一个问题(播放中有红旗)。
我尝试排除文件,但再次无法正常工作。
我后来发现chilkat
是购买的ftp,并且源代码是私有的。因此,(Source code omitted for this binary file)
输出中的错误。我不确定这是阻止karma
工作的原因还是什么原因。
我正在寻找另一个跟踪路径,否则我将不得不重新插入一些SW管道以将ftp chilkat
代码部分分成一个单独的文件,以便不包括{{1 }}在单元测试代码中的依赖性。
感谢任何标准实践反馈,因为我需要为其他范围蠕变辩护。我认为任何FTP测试都应该是系统测试,这也许就是为什么我对单元测试没有看到chilkat
的原因。
先谢谢了。 〜迈克
chilkat
#Trimmed down unit test code to demonstrate issue:
const chilkat = require('chilkat_node8_win32');
const ftp = new chilkat.Ftp2();
#karma.config.js
module.exports = function (config) {
config.set({
//root path location to resolve paths defined in files and exclude
basePath: '',
//files/patterns to exclude from loaded files
exclude: [ '/**/chilkat.node' ], // <--- attempt to exclude
...
webpack: {
externals: ['pg', 'sqlite3', 'tedious', 'pg-hstore'],
module: {
rules: [
{
test: /\.js$/i,
exclude: '/**/chilkat.node', // <--- attempt to exclude
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
]
},
node: { fs: 'empty', child_process: 'empty', dns: 'empty', net: 'empty', tls: 'empty', hstore: 'empty', chilkat_node8_win32: 'empty' } // <--- attempt to enable
},
preprocessors: {
//add webpack as preprocessor to support require() in test-suits .js files
'./test/*.js': ['webpack']
},