Last active
March 10, 2022 20:57
-
-
Save odlp/e1586f4f198d157de50e8303b18acfd9 to your computer and use it in GitHub Desktop.
Jasmine / Karma seed reporter for random test order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SeedReporter = function(baseReporterDecorator) { | |
baseReporterDecorator(this); | |
this.onBrowserComplete = function(browser, result) { | |
if (result.order && result.order.random && result.order.seed) { | |
this.write("%s: Randomized with seed %s\n", browser, result.order.seed); | |
} | |
}; | |
}; | |
module.exports = { | |
"reporter:jasmine-seed": ["type", SeedReporter] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jasmineSeedReporter = require("./spec/javascript/support/jasmine_seed_reporter.js") | |
module.exports = function(config) { | |
// abridged | |
plugins: [ | |
"karma-*", | |
jasmineSeedReporter | |
], | |
reporters: ["progress", "jasmine-seed"], | |
client: { | |
jasmine: { | |
random: true | |
// seed: 1234 // Specify if you need to re-run the same seed | |
} | |
} | |
} |
Thanks @Furg - that comment saved me hours...
Is there a way to print the seed before the tests start? We have a specific issue where an error is thrown in the after all and therefore throwing the error all the way up it seems. So since the tests can't complete I don't get the seed value to replicate.
@douglasrlee - I haven't tried it, but this reporter seems to print the seed before & after the spec run which might help you: https://github.com/dmitryshindin/karma-jasmine-order-reporter
@douglasrlee - I haven't tried it, but this reporter seems to print the seed before & after the spec run which might help you: https://github.com/dmitryshindin/karma-jasmine-order-reporter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for this solution 👍
By the way i found what logs is duplicate with this reporter and fix it add stub for
onBrowserLog
. Maybe it help somebody else.