I have been attempting to set up functional testing using Intern 4 with a headless Chrome browser. I have installed selenium-server-standalone
on my Mac terminal and believe everything is configured correctly. However, when I try to run the test, I encounter the following error:
Running "exec:test_functional" (exec) task
Listening on localhost:9000 (ws 9001)
Tunnel started
BUG: suiteEnd was received for invalid session
(ノಠ益ಠ)ノ彡┻━┻
UnknownError: [POST http://localhost:4444/wd/hub/session / {"desiredCapabilities":{"name":"intern","idle-timeout":60,"browserName":"chrome","goog:chromeOptions":{"args":["headless","disable-gpu"]}}}] Cannot define class using reflection
at Server.post <tests/node_modules/src/Server.ts:367:14>
at Server.createSession <tests/node_modules/src/Server.ts:412:14>
at Suite.before <tests/src/lib/executors/Node.ts:469:8>
at <tests/src/lib/Suite.ts:388:19>
at new Task <tests/node_modules/@dojo/core/async/Task.ts:239:3>
at runLifecycleMethod <tests/src/lib/Suite.ts:355:10>
at before <tests/src/lib/Suite.ts:458:10>
at Suite.run <tests/src/lib/Suite.ts:477:6>
at <tests/src/lib/executors/Node.ts:821:20>
at FunctionQueue.next <tests/src/lib/executors/Node.ts:945:16>
TOTAL: tested 0 platforms, 0 passed, 0 failed; fatal error occurred
>> Exited with code: 1.
>> Error executing child process: Error: Process exited with code 1.
Warning: Task "exec:test_functional" failed. Use --force to continue.
Aborted due to warnings.
I am using the latest versions of Node, npm, and Intern.
Any assistance in resolving this issue would be greatly appreciated.
EDIT:
app.ts
// tests/functional/app.ts
const { suite, before, test } = intern.getPlugin("interface.tdd");
const { expect, assert } = intern.getPlugin("chai");
suite("app", () => {
before(({ remote }) => {
return remote
.get("src/app.html")
.setFindTimeout(5000)
.findDisplayedByCssSelector("body");
});
let windowHandles: any;
test("testing", ({ remote }) => {
return remote
// Click login button
.findByClassName('hero-cta')
.click()
.end()
// Switch to login window
.getAllWindowHandles()
.then(function(handles: string[]){
windowHandles = handles;
assert.isArray(windowHandles);
return remote.switchToWindow(windowHandles[1]);
})
// Input user credentials and submit
.findById('user_username')
.type('username')
.end()
.findById('user_password')
.type('password')
.findAllByCssSelector('button')
.click()
.end()
//Switch to app
.getAllWindowHandles()
.then(function(handles: string[]){
assert.isArray(handles);
return remote.switchToWindow(windowHandles[0]);
})
.find('css selector','span')
.getVisibleText()
.then(function(text: string) {
console.log(text);
})
});
});
intern.json
{
...
"environments": [
{
"browserName": "chrome",
"goog:chromeOptions": {
"args": ["headless", "disable-gpu"]
}
}
]
}