Skip to content
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

fix(jasmine): unhanded promise rejection causes tests suit to pass #2707

Merged
merged 1 commit into from
May 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/jasmine/jasmine_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function readArg() {
return process.argv.splice(2, 1)[0];
}

function main(args) {
async function main(args) {
if (args.length < 2) {
throw new Error('expected argument missing');
}
Expand Down Expand Up @@ -133,7 +133,7 @@ function main(args) {
// Patch the inner execute function to do our filtering first.
const env = jasmine.getEnv();
const originalExecute = env.execute.bind(env);
env.execute = () => {
env.execute = async () => {
const allSpecs = getAllSpecs(env);
// Partition the specs among the shards.
// This ensures that the specs are evenly divided over the shards.
Expand All @@ -144,7 +144,7 @@ function main(args) {
const end = allSpecs.length * (SHARD_INDEX + 1) / TOTAL_SHARDS;
const enabledSpecs = allSpecs.slice(start, end);
env.configure({specFilter: (s) => enabledSpecs.includes(s.id)});
originalExecute();
await originalExecute();
};
// Special case!
// To allow us to test sharding, always run the specs in the order they are declared
Expand All @@ -154,7 +154,8 @@ function main(args) {
}
}

jrunner.execute();
await jrunner.execute();

return 0;
}

Expand All @@ -176,5 +177,12 @@ function getAllSpecs(jasmineEnv) {
}

if (require.main === module) {
process.exitCode = main(process.argv.slice(2));
(async () => {
try {
process.exitCode = await main(process.argv.slice(2));
} catch (error) {
console.error('[jasmine_runner.js] An error has been reported:', error);
process.exitCode = 1;
}
})();
}