Skip to content

Conversation

@robgonnella
Copy link

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: #8

@haadcode
Copy link
Owner

haadcode commented Aug 1, 2018

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.html should prolly go under test directory. What do you think?
  • In the browser test index file, dist/logplease.min.js is 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 in es5 directory 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?

@robgonnella robgonnella force-pushed the issue-8-run-tests-in-browser branch 2 times, most recently from 3410f94 to 2d53bfa Compare August 2, 2018 02:47
@robgonnella
Copy link
Author

robgonnella commented Aug 2, 2018

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?

  • All tests are back to being in one file logplease.test.js
  • All tests are run by default on npm run test
  • browser tests html file moved to test directory
  • Use es5 source so stack trace is not lost

@robgonnella robgonnella force-pushed the issue-8-run-tests-in-browser branch from 2d53bfa to b88afe9 Compare August 2, 2018 03:21
Updates test infrastructure to use grunt-mocha / phantomJS to run
the tests in a browser.

Resolves Issue: haadcode#8
@robgonnella robgonnella force-pushed the issue-8-run-tests-in-browser branch from b88afe9 to 86cdad1 Compare August 2, 2018 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants