logplease
logplease copied to clipboard
Run tests in browser
Runs relevant tests in browser using puppeteer package. Results are captured in a snapshot with duration information hidden and compared against an image of the last known passing image run. This is a bit brittle in that it requires manually updating the current passing screenshot when browser tests are modified.
Resolves Issue: https://github.com/haadcode/logplease/issues/8
Thank you @robgonnella for the PR! 👍 It would be great to make the tests run in a browser.
However, there's couple of things here that I think needs to be addressed before this can be merged:
- Browser tests in
logplease.browser.test.js- we should not create a duplicate test file for the browser tests as it means we'd have to add each test to both test files. Rather, we should use the same tests for both (all) environments. This may require some refactoring of how node.js tests are setup and run in order to remove the node.js-specific dependencies (such as fs). It would make sense to separate the log-file tests to its own file and leave those out from the browser tests. - If we add browser tests, we should run all tests by default on
npm test - The index file for browser tests,
index.htmlshould prolly go under test directory. What do you think? - In the browser test index file,
dist/logplease.min.jsis included and that prolly means that upon test failure, we lose the stack trace (as it's all minified code). it would make sense to include the source ines5directory as that contains non-minified build. - You mention "...compared against an image of the last known passing image run" but the screenshot produced by the browser tests is added to
.gitignore. How do we know what is the "last known passing image run"? Would it make sense to not compare the images and rather check the output of the test run?
Ok thought about it a bit and took a better approach using grunt-mocha and phantomjs. I was able to complete everything you asked except using the es5 source code instead of the minified code. I wasn't able to get the es5 code to load properly. Do you have any ideas on how to solve this issue? Or maybe you want to take it in a follow-up PR?
- [x] All tests are back to being in one file
logplease.test.js - [x] All tests are run by default on
npm run test - [x] browser tests html file moved to test directory
- [ ] Use es5 source so stack trace is not lost