async keyword causes test to be seen as single promise => timeout too short
See original GitHub issueDescription
When using Node 8, transpiling all, and babel-preset-env with node:true
as target, some of my longer tests time out via finishDueToInactivity
. This doesn’t happen when the async is transpiled by babel. I assume that the async creates a single promise where the transpiled version splits in many?
If so, I propose that the timeout gets reset every time one of the test functions gets called?
Test Source
test('long test with many steps', async t => {
t.snapshot(await slowThing1(), 'after 1')
t.snapshot(await slowThing2(), 'after 2')
// ... Sometime here it will say "Promise returned by test never resolved"
t.snapshot(await slowThing8(), 'after 8')
})
Error Message & Stack Trace
Promise returned by test never resolved
Test.finishDueToInactivity (node_modules/ava/lib/test.js:377:7)
onBeforeExit (node_modules/ava/lib/sequence.js:43:20)
process.beforeExitHandler (node_modules/ava/lib/sequence.js:6:3)
processEmit [as emit] (node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js:146:32)
Config
Copy the relevant section from package.json
:
{
"ava": {
"files": [
"{src,lib}/**/{__tests__/*,*.test}.js{,x}"
],
"babel": "inherit",
"concurrency": 5,
"require": [
"babel-register",
"babel-polyfill"
]
}
}
Command-Line Arguments
Copy your npm build scripts or the ava
command used:
ava --watch
Environment
Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:
Node.js v8.4.0
darwin 16.5.0
0.22.0
5.3.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Jest: Timer and Promise don't work well. (setTimeout and ...
Fortunately it is actually quite easy to let all pending jobs in PromiseJobs run within an async test, all you need to do...
Read more >async function - JavaScript - MDN Web Docs - Mozilla
The async function declaration declares an async function where the await keyword is permitted within the function body. The async and await ...
Read more >Testing-library: avoid these mistakes in async tests
In our test, when we are calling render with await , JavaScript implicitly wraps the result into a promise and waits for it...
Read more >Async Methods - Testing Library
The async methods return Promises, so be sure to use await or .then when ... hopefully make it easier to track down what...
Read more >How to use React Testing library to wait for async elements, a ...
JavaScript is a single-threaded and asynchronous language which is a ... in an async way using Promises and the newer async/await syntax.
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 Free
Top 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
@Smilebags could you share your example?
I am also experiencing this issue with a rather simple example.