-
Notifications
You must be signed in to change notification settings - Fork 164
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
Optional chaining rewriting by Hammerhead causes TypeError: undefined has no properties #3012
Comments
Thank you for submitting a bug report. We would love to help you investigate the issue. Please share a simple code example that reliably reproduces the bug. For more information, read the following article: How To Create a Minimal Working Example When You Submit an Issue. We look forward to your response. |
The test below passes in Chrome but fails in Firefox with a index.html <!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>TestCafe</title>
</head>
<body>
<script>
const worker = new Worker('worker.js');
worker.onmessage = e => {
console.log(e.data);
};
</script>
</body>
</html> worker.js const asyncThunkSymbol = 'asyncThunkSymbol';
function buildCreateSlice({ creators } = {}) {
return creators?.asyncThunk?.[asyncThunkSymbol];
}
try {
const shouldBeUndefined = buildCreateSlice();
postMessage(`OK: ${shouldBeUndefined}`);
} catch (error) {
postMessage(error);
} index.spec.js const express = require('express');
const PORT = 3000;
let server;
fixture`Fixture`
.page(`http://localhost:${PORT}/index.html`)
.before(() => {
const app = express();
app.use(express.static(__dirname));
server = app.listen(PORT);
})
.after(() => {
server.close();
});
test('test', async t => {
await t.wait(1000);
const { log } = await t.getBrowserConsoleMessages();
console.log('worker logs: ', log);
await t.expect(log[0]).match(/^OK:/);
}); |
Hello @Bayheck, Any progress on this issue? |
Hello @Bayheck, Any chance this bug gets fixed in a near future? |
We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news. |
What is your Scenario?
My application uses
@reduxjs/toolkit
that contains the following function (see here):What is the Current behavior?
The functionality that I am testing works well in Firefox. However, when I run the TestCafe test, it fails with a
TypeError: undefined has no properties
. This is caused by the transformation that is applied by Hammerhead.The code is transformed from this:
into this, which throws a
TypeError
whencreators?.asyncThunk
isundefined
:What is the Expected behavior?
The behaviour of
creators?.asyncThunk?.[asyncThunkSymbol]
should be preserved after the transformation.What is your public website URL? (or attach your complete example)
NA
What is your TestCafe test code?
NA
Your complete configuration file
No response
Your complete test report
No response
Screenshots
No response
Steps to Reproduce
NA
TestCafe version
3.6.2
Node.js version
No response
Command-line arguments
testcafe firefox -e
Browser name(s) and version(s)
No response
Platform(s) and version(s)
No response
Other
No response
The text was updated successfully, but these errors were encountered: