-
Notifications
You must be signed in to change notification settings - Fork 81
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
Decide and implement unit testing framework #159
Comments
codecov.io free for open source |
Browserstack for running on browsers in the cloud and some extension tips: |
https://github.com/microsoft/tsyringe Especially for testing with modules, we may want dependency injection for easier stubbing. |
Started working on this for #366 since it should have a test. Currently using a karma + jasmine with headless chrome as per #159 (comment) minus mocha For typescript, I had tried karma-typescript plugin but it didn't work with es6 well so instead I switched to using karma-webpack since I already use that for production. As part of this, I also ended up making a separate tsconfig for ts-node so that I could have advanced es6 enabled for my code and use legacy modules for node TS files (configs and update-db). I'll probably split that part out since I don't think it's related to getting testing working. It will be useful if it allows me to use top level awaits though! In my attempts to get a idiomatic setup and everything working I took a circuitous path but the following resources were most helpful:
Things seem to work as well as I could expect now for unit testing though I still need to write a real working test. Other things to come later is full integration test as well as code coverage via something like codecov.io or just native karma coverage plugin (combined with github action etc) |
Update: This style guide for jasmine is pretty good except for the examples moving setup into I decided to not use the sinon chrome stuff since the jasmine integration didn't work well. Instead, I made my own chrome fake with Jasmine spys for the functions. It can be easily expanded as tests are added. |
Updates: I added a spy reset method to my fake chrome since otherwise it just accumulates method call recordings. It seems I didn't need any specific sourcemap stuff in my launch.json for some reason. Perhaps due to inline source maps? I feel like I don't need webpack since I can use ES modules directly but I'd need something to extract the node deps like lit into something that can be used easily! Maybe snowpack can be looked at again now that I'm a bit more knowledable. |
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: Jasmine + Karma + Headless Chrome. Works with vscode debugging for fast test driven development. Unrelated changes required for compilation: - options.ts my LitToast interface needed to extend `Element` when compiling with karma and tsc. Not sure why it worked with `ts-loader` - I needed to update webpack.config to accept a partial argv since of course we are only using `mode`. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: Jasmine + Karma + Headless Chrome. Works with vscode debugging for fast test driven development. Unrelated changes required for compilation: - options.ts my LitToast interface needed to extend `Element` when compiling with karma and tsc. Not sure why it worked with `ts-loader` - I needed to update webpack.config to accept a partial argv since of course we are only using `mode`. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: Jasmine + Karma + Headless Chrome. Works with vscode debugging for fast test driven development. Unrelated changes required for compilation: - options.ts my LitToast interface needed to extend `Element` when compiling with karma and tsc. Not sure why it worked with `ts-loader` - I needed to update webpack.config to accept a partial argv since of course we are only using `mode`. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. Fixes #366 Fixes #159
After doing all of this I decided to try out snowpack for the build tool and it worked better than expected and then I followed that thread to get a matching test setup as well since it's always better for tests to match production as much as possible. The recommended test runner is @web/test-runner which is new but also built for modern web. I came across some problems trying to use it:
On the other hand after that most things worked directly:
The final result is a fast test and useful test runner. |
Future ideas: Create medium sized unit tests by using connecting content script to background scripts with custom |
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. With --coverage flag, we get a coverage report that we can upload to codecov. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. With --coverage flag, we get a coverage report that we can upload to codecov. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. With --coverage flag, we get a coverage report that we can upload to codecov. Fixes #366 Fixes #159
Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. With --coverage flag, we get a coverage report that we can upload to codecov. Fixes #366 Fixes #159
…use (#561) Specifically, ignore `display: none` and `visibility: hidden`. This change is also the first unit tested change so contains the initial configuration of testing. (See #159 for details on decisions). Testing Stack: @web/test-runner + Mocha/Chai/Sinon + Puppeteer Headless Chrome. Works with vscode debugging for fast test driven development. With --coverage flag, we get a coverage report that we can upload to codecov. Fixes #366 Fixes #159
## [2.0.0](v1.2.6...v2.0.0) (2021-07-17) ### ⚠ BREAKING CHANGES * This version includes optional chaining requiring Chrome >=80 ### Features * Force Google Docs to use HTML mode instead of canvas mode ([#596](#596)) ([94b60a6](94b60a6)), closes [#593](#593) * **detection:** Ignore invisible nodes when extracting text under mouse ([#561](#561)) ([cb97f36](cb97f36)), closes [#159](#159) [#366](#366) [#159](#159) ### Bug Fixes * **dict:** Update dictionaries to latest versions. ([#581](#581)) ([77189c3](77189c3)) * Skip text processing when range is null ([#598](#598)) ([ae55bff](ae55bff)), closes [#386](#386) ### Code Refactoring * Migrate from webpack to snowpack for build step ([#583](#583)) ([1bdd3d3](1bdd3d3))
🎉 This issue has been resolved in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Probably use Jasmine with karma?
At first should add test harness and a couple of tests as proof of concept.
(maybe add some incremental coverage measurements)
The text was updated successfully, but these errors were encountered: