-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
doesn't work with jest #156
Comments
I'm having the same problem, is there any way to solve this or is there a fix already? |
Same here, any workarounds are welcome |
same on me |
any solution ? |
In native Node.js tests, it can also result in an infinite loop. For example, the following three code snippets, a and c are the same, but c cannot run successfully because it is inside a test. node - v18.19.0 const deasync = require('deasync');
const test = require('node:test');
function async2sync (fn) {
return (...args) => {
var done = false;
var data;
fn(...args).then((res) => {
data = res
}).catch(err => {
throw err
}).finally(() => {
done = true
})
deasync.loopWhile(() => !done);
return data
}
}
{ // a
console.log(1)
console.log(async2sync(async () => 2)())
console.log(3)
}
{ // b
test('synchronous passing test', (t) => {
console.log(1)
console.log(2)
console.log(3)
});
}
{ // c
test('synchronous passing test', (t) => {
console.log(1)
console.log(async2sync(async () => 2)())
console.log(3)
});
} Using this code snippet also faces the same issue. function async2sync (fn) {
return (...args) => {
return deasync(async (cb) => {
const res = await fn(...args)
cb(undefined, res)
})()
}
} |
when running the following code with
node file.js
it works, but when running the same code withjest
it just runs continuouslyconsole displays '====1===', but doesn't display '===2==='
The text was updated successfully, but these errors were encountered: