Async/blocking BeforeSuite, Before, After, AfterSuite hooks
See original GitHub issueWhat are you trying to achieve?
I would like to asynchronously create a test user and a test project over an XHR request before a collection of tests runs.
I expected one of the following to work:
BeforeSuite((I) => new Promise((resolve) => setTimeout(resolve, 5000)))
Before((I) => new Promise((resolve) => setTimeout(resolve, 5000)))
BeforeSuite(function* (I) {
yield new Promise((resolve) => setTimeout(resolve, 5000))
})
Before(function* (I) {
yield new Promise((resolve) => setTimeout(resolve, 5000))
})
What do you get instead?
Instead, the tests progress without any blocking/waiting. Is there any approach I can take to postbone test execution until my prerequisits are fulfilled?
Details
- CodeceptJS version: v0.5.1
- NodeJS Version: v7.2
- Operating System: MacOS Sierra
- WebDriverIO version: v4.6.2
- Configuration file:
exports.config = {
tests: './tests/src/end-to-end/**/*.[tj]s',
timeout: 10000,
output: './tests/output/end-to-end',
helpers: {
WebDriverIO: {
url: process.env.GUI_HOST,
browser: 'chrome',
restart: true,
desiredCapabilities: {
browserName: 'chrome',
},
host: 'selenium',
port: 4444,
},
TestUser: {
"require": "./tests/config/codecept/TestUser.js",
},
TestBusinessEntity: {
"require": "./tests/config/codecept/TestBusinessEntity.js",
},
},
include: {
I: './tests/config/codecept/custom_steps.js',
},
bootstrap: false,
mocha: {},
name: 'byll-gui',
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Async/blocking BeforeSuite, Before, After, AfterSuite hooks #436
I would like to asynchronously create a test user and a test project over an XHR request before a collection of tests runs....
Read more >Behat: BeforeSuite and AfterSuite Hooks - ProgramsBuzz
Suite hooks are run outside of the scenario context. It means that your context class (e.g. FeatureContext) is not instantiated yet and the ......
Read more >How to use TestNG BeforeSuite and AfterSuite Hooks for ...
In this post, we will see, how to create a database connection only once and how to close the connection once using TestNG...
Read more >Bountysource
Async/blocking BeforeSuite, Before, After, AfterSuite hooks. ... Help and Information. Frequently Asked Questions · Bugs and Feature Requests · Fees ...
Read more >Cucumber Reports - BeforeSuite and AfterSuite methods
Standard Cucumber runner has functionality of hooks which is represented with @Before and @After annotations and which are running before and after each ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, promises are stored in a global promise chain. There is a way to access it (I will post it below, however it is not documented and not recommended to do so). To attach a promise to a promise chain it should be implemented as a method inside a helper and called inside a test:
doSomethingBeforeStart
should be defined inside a custom helper as a regular method returning a promise:Once the helper is enabled you can use its method inside Before/BeforeSuite.
Alternatively you can access a promise chain on your own
@sveneisenschmidt unfortunately I have not, I used a test to achieve what I wanted. Let us know if you find a solution!