-
-
Notifications
You must be signed in to change notification settings - Fork 736
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
Ensure scenario termination #4378
Merged
kobenguyent
merged 14 commits into
codeceptjs:fix/stale-process
from
Horsty80:ensure-scenario-termination
Jun 7, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5f38321
chore: Add test:stale script for running state_test.js
Horsty80 769b8d6
fix: handle async function better to prevent stale the process
Horsty80 cfc0be5
fix: done() call multiple times
Horsty80 de24891
chore: rename files and test description
Horsty80 5eb28d8
fix: playwright error on test
Horsty80 5212c61
fix: stale process due to retryTo error handler
Horsty80 5ac84bd
Merge branch 'codeceptjs:3.x' into ensure-scenario-termination
Horsty80 89275b2
fix: lint previous code
Horsty80 2f3134f
Merge branch 'fix/stale-process' into ensure-scenario-termination
kobenguyent 0e3870b
Merge branch 'codeceptjs:3.x' into ensure-scenario-termination
Horsty80 8dd36d3
fix: error due to the previous merge
Horsty80 2a7d68e
fix: handle async function better to prevent stale the process
Horsty80 09db07e
fix: lint previous code
Horsty80 21064cd
Merge branch 'fix/stale-process' into ensure-scenario-termination
kobenguyent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
exports.config = { | ||
tests: './test.scenario-stale.js', | ||
timeout: 10000, | ||
retry: 2, | ||
output: './output', | ||
include: {}, | ||
bootstrap: false, | ||
mocha: {}, | ||
name: 'sandbox', | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Feature('Scenario should not be staling'); | ||
|
||
const SHOULD_NOT_STALE = 'should not stale scenario error'; | ||
|
||
Scenario('Rejected promise should not stale the process', async () => { | ||
await new Promise((_resolve, reject) => setTimeout(reject(new Error(SHOULD_NOT_STALE)), 500)); | ||
}); | ||
|
||
Scenario('Should handle throw inside synchronous and terminate gracefully', () => { | ||
throw new Error(SHOULD_NOT_STALE); | ||
}); | ||
Scenario('Should handle throw inside async and terminate gracefully', async () => { | ||
throw new Error(SHOULD_NOT_STALE); | ||
}); | ||
|
||
Scenario('Should throw, retry and keep failing', async () => { | ||
setTimeout(() => { | ||
throw new Error(SHOULD_NOT_STALE); | ||
}, 500); | ||
await new Promise((resolve) => setTimeout(resolve, 300)); | ||
throw new Error(SHOULD_NOT_STALE); | ||
}).retry(2); |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { expect } = require('expect'); | ||
const path = require('path'); | ||
const { exec } = require('child_process'); | ||
|
||
const runner = path.join(__dirname, '/../../bin/codecept.js'); | ||
const codecept_dir = path.join(__dirname, '/../data/sandbox'); | ||
const codecept_run = `${runner} run`; | ||
const config_run_config = config => `${codecept_run} --config ${codecept_dir}/${config}`; | ||
|
||
describe('Scenario termination check', () => { | ||
before(() => { | ||
process.chdir(codecept_dir); | ||
}); | ||
|
||
it('Should always fail and terminate', (done) => { | ||
exec(config_run_config('codecept.scenario-stale.js'), (err, stdout) => { | ||
expect(stdout).toContain('should not stale scenario error'); // feature | ||
expect(err).toBeTruthy(); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if done() should be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test case that i added passed with the resolve promise so i guess it's enough ^^
Just
retryTo
will be update with my other pr, so when the first it's merge, i will update this fileI think it's a good practice to add the
catch
block when we add something to the recorder i presumeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I meant
done()
instead ofdone(null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The done is the
resolve
of the promise and I get this typeand in the file, done function already call with
done(null)
🤷♂️