我正在开发箱上运行Karma / Jasmine / Angular 2.0测试。就在最近,我开发箱上的Jasmine决定开始运行我的测试3次。是的,每次精确地三遍。
在第一次运行时,一切都按预期通过。但是,在第二遍和第三遍,所有相同的事情都会失败。它总是承认有7个测试,但是运行21个,有10个失败(窗口之外的一年级数学)????
[这也是SauceLabs的fails on Travis。 (注:链接到具有3个测试的较早版本,但运行9个,而5个失败?)]
我有一个屏幕快照,karma.conf.js文件和一个启动整个过程的套件。任何帮助将不胜感激。
describe('From the Conductor Service', () => {
let arr: Array<ComponentStatusModel> = null;
let svc: ConductorService = null;
beforeEach(() => {
arr = [/* Inits the array*/];
svc = new ConductorService();
});
describe('when it is handed a container to hold objects which need loaded', () => {
// More passing tests...
/// vvvvv The culprit !!!!!
describe('then when you need to access the container', () => {
beforeEach(() => {
svc.loadedContainer = arr;
});
it('it should always be available', () => {
assertIsLocalDataInTheService(arr, svc.loadedContainer);
});
});
/// ^^^^^ End of culprit !!!!!
});
// More passing tests...
});
不确定是否相关,但是在所有错误发生之前,Jasmine调用堆栈会较小(左,请观察滚动条)。错误开始后,通过重复调用相同的函数,堆栈变得更大了(对,请观察滚动条)。
在我的测试中,Nanobar和Conductor规格文件完全分开。但是,您可以看到套件阵列包含Nanobar和Conductor规范中的内容。通过某种方式,Jasmine将这两个spec文件混在一起(一切都开始失败之后),并导致我的describe()语句发布到控制台时毫无意义。
module.exports = function (config) {
config.set({
autoWatch: false,
basePath: '.',
browsers: ['Chrome'],
colors: true,
frameworks: ['jasmine'],
logLevel: config.LOG_INFO,
port: 9876,
reporters: ['coverage', 'progress'],
singleRun: true,
coverageReporter: {
// Code coverage config
},
files: [
// Loads everything I need to work
],
plugins: [
'karma-chrome-launcher',
'karma-coverage',
'karma-jasmine'
],
preprocessors: {
'app/**/*.js': ['coverage']
},
proxies: {
// Adjust the paths
}
})
}
好,首先,您发布的信息太多,将挑战想要帮助的人。
第二,我不知道解决方案,但是如果您尝试使用相同的配置创建另一个新的独立测试,请查看问题是否存在,然后您可以判断代码是否有问题或配置。
第三,通过给他们简化的问题在jsfiddle或任何在线代码共享站的联系,与支持团队联系。
谢谢,请将此设为您的答案!只是在开玩笑,看看是否有帮助并奖励我!
快乐编码!