Open breml opened 6 years ago
@breml good question.
gopherjs test
uses the Node environment; hence the window
global is not available.
For this reason I wrote (the very basic) myitcv.io/gjbt
which enables you to run tests within a headless Chrome instance.
The myitcv.io/react
tests themselves use this approach.
Skeleton tests for all of the generated elements are themselves also generated in case you need any inspiration, e.g. the <a>
element tests.
Let me know how you get on.
@myitcv I tried gjbt
, but this does not yet look clean to me.
I installed chromedriver
, added the init_test.go
file as suggested and run gjbt .
. I then get this output:
ok github.com/breml/reacttest/test 0.046s
panic: failed to retrieve logs: unexpected response: {"sessionId":"a6fa970438e2285d182fe582c707e7a2","status":6,"value":{"message":"no such session\n (Driver info: chromedriver=2.9.248304,platform=Linux 4.4.0-122-generic x86_64)"}}
goroutine 1 [running]:
main.main()
/home/lubr/code/go/src/github.com/myitcv/gjbt/main.go:163 +0xe8b
It looks like the test have been executed (and are successful), but I still get the above mentioned panic. Do you have an idea why this happens?
@breml there have been a few more commits recently to gjbt
(as well as some improve documentation) which probably fix the issue you've seen. Please can you give it another try?
In particular, the README now lists requirements:
I tried to write tests in combination with this package. I tired with this minimal file (react_test.go):
If I execute
go test .
, the following output is given:If I use
gopherjs tes .
, then the output is: