I am running Karma/Jasmine/Angular 2.0 tests on my development box. Just recently, Jasmine on my development box decided to start running my tests three times. Yes, exactly three times, every time.
On the first run, everything passes as expected. However, on the second and third pass, all of the same things fail. It always acknowledges that there are 7 tests, but runs 21, and 10 fails (first-grade math out the window)????
This also fails on Travis with SauceLabs. (Note: That links to an older build with 3 tests, but ran 9, and 5 fail???)
I have a screenshot, karma.conf.js file, and one suite which started this whole thing. Any help with be greatly appreciated.
Full source
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 to be 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... });
Not sure if this is related, but before all of the errors happen, the Jasmine call stack is smaller (left, observe scrollbar). After the errors start, the stack just gets bigger with repeating calls to the same functions (right, observe scrollbar).
In my test, the Nanobar and Conductor spec files are totally separate. However, you can see the suites array includes stuff from the Nanobar and Conductor specs. Somehow Jasmine mashed these two spec files together (after everything started failing), and resulted in my describe() statements not making any sense when published to the console.
Full source
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 } }) }
Can you try refreshing your browser in your first assertion in each of your test files? Try this:
browser.restart();
I had the same problem and this fixed it for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With