-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests seem to start before previous test has finished #1379
Comments
This depends not only on karma, but also on the testrunner and bundling tools you are using. Can you describe your setup more closely? |
the bundling of files are finished before the tests begin. I happen to be using browserify to bundle my JS, but as i say, this is complete before test begin. my karma file : module.exports = function(config) {
var karmaConfig = {
basePath: '..',
browsers: ['PhantomJS'],
frameworks: ['jasmine', 'browserify'],
reporters: ['progress'],
preprocessors: {
'test/functional/**/*.js': ['browserify'],
'_site/*.html': ['html2js']
},
plugins: [
'karma-browserify', 'karma-jasmine', 'karma-coverage', 'karma-phantomjs-launcher', 'karma-chrome-launcher', 'karma-html2js-preprocessor'
],
files: [
{pattern: '_site/**/vendor.*', included: true, served: true, watched: true},//vendor must be first
{pattern: '_site/**/*.*', included: true, served: true, watched: true},
'test/functional/**/*.spec.js'
],
exclude: [
'**/*.png',
'src/**/*.requirejs.js',
'**/*.min.js',
'src/**/*.txt',
'src/**/*.csv',
'src/**/*.hbs'
]
};
var pkg = require('../package.json');
karmaConfig.browser = pkg.browser || {};
karmaConfig["browserify-shim"] = pkg["browserify-shim"] || {};
karmaConfig.browserify = pkg.browserify || {};
return config.set(karmaConfig);
}; to run the tests I don't use gulp or grunt or anything, just node 'api' karma provides : function run(singleRun, configPath){
return new Promise(function(resolve, reject) {
karma.start({
configFile: configPath,
singleRun: singleRun
}, function(err){
err && reject(err);
!err && resolve();
});
});
}; |
|
It seems as if my
document.body.innerHTML
is being overridden by the subsequent test. When run in sequence, my test fails as it can not find the correct HTML element to test against. When running a single spec file, the tests pass.This leads me to believe that the next
describe
functions are being executed before the previous spec has finished.Is there a way to ensure that the test have finished before moving onto the next spec file?
At the top of my functional tests I load assets onto the page and update the html using:
require('../helper').loadAssets('my-page-name');
helper.js
I have fixed this by hacking the spec and adding
The text was updated successfully, but these errors were encountered: