Node.js chilkat ftp给单元测试karma一个意外的字符'';二进制文件出错
我必须用一些继承的代码创建一些单元测试。 所有代码都在一个大文件中,最终需要分开。 我的Node.js chilkat ftp给单元测试karma一个意外的字符'';二进制文件出错,node.js,unit-testing,karma-jasmine,chilkat,Node.js,Unit Testing,Karma Jasmine,Chilkat,我必须用一些继承的代码创建一些单元测试。 所有代码都在一个大文件中,最终需要分开。 我的karmajasmine单元测试拉入了这个引用chilkat\u node8\u win32的大文件。我的测试用例没有运行chilkat。我似乎无法从karma.config.js中排除chilkat。chilkat在代码中,而不是单独的文件 我已经在操作上设置并成功测试了hello worldkarma单元测试。然后我开始测试目标代码,出现了各种配置错误。我只剩下最后一个了 环顾四周后。。。我找不到任何与c
karmajasmine
单元测试拉入了这个引用chilkat\u node8\u win32
的大文件。我的测试用例没有运行chilkat
。我似乎无法从karma.config.js
中排除chilkat
。chilkat
在代码中,而不是单独的文件
我已经在操作上设置并成功测试了hello worldkarma
单元测试。然后我开始测试目标代码,出现了各种配置错误。我只剩下最后一个了
环顾四周后。。。我找不到任何与chilkat
相关的karma
单元测试,这在python
中不是一个死链接,也没有给我的防病毒带来问题(我在游戏中有危险信号)
我试图排除该文件,但再次失败
我后来发现chilkat
是一个购买的ftp,源代码是私有的。因此,(此二进制文件的源代码被省略)
的输出出现错误。我不确定这是否是阻止业力发挥作用的原因,或者是什么原因
我正在寻找另一条面包屑路径,否则我将不得不重新竖直一些SW管道,将ftpchilkat
代码部分分离到一个单独的文件中,以便在单元测试代码中不包含chilkat
依赖性
感谢任何标准实践反馈,因为我需要为额外的范围扩展提供理由。我认为任何FTP测试都应该是系统测试,这可能就是为什么我看不到关于单元测试的chilkat
提前谢谢。
~z~迈克
Chilkat库的黑盒特性总是让它们成为问题。如果你真的在这里摔跤,这里有很多。谢谢@tadman的快速响应。
#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']
},
Error
$ npm test
...
> karma start karma.conf.js
i 「wdm」: Compiled with warnings.
START:
i 「wdm」: Compiling...
× 「wdm」:
ERROR in ./node_modules/chilkat_node8_win32/chilkat.node 1:2
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
@ ./lib/modules/ABC.js 1:14-44
@ ./test/test.js
i 「wdm」: Failed to compile.