Skip to content

Commit

Permalink
Migrate JS tests to jasmine-browser-runner (Fixes #40) (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson authored Nov 13, 2023
1 parent fce18ff commit e43de00
Show file tree
Hide file tree
Showing 12 changed files with 1,667 additions and 1,660 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
},
overrides: [
{
// JS Karma test files.
// Jasmine test files.
files: ['tests/**/*.js'],
env: {
jasmine: true
Expand Down
35 changes: 19 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ on:
branches:
- main
jobs:
test:
runs-on: ubuntu-20.04 # Using pinned version instead of -latest until https://github.com/actions/runner-images/issues/6704 is resolved.
name: 'Test'
steps:
- name: 'Ensure a recent Firefox and the xvfb framebuffer are installed'
run: |
sudo apt-get update
sudo apt-get install xvfb firefox
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: 'Install NPM deps'
run: npm install
- name: 'Run JS tests in headless mode, thanks to xvfb'
run: xvfb-run npm test
test:
runs-on: ubuntu-20.04
# NB: this workflow fails on Ubuntu 22.04 (AKA ubuntu-latest) because the
# browsers are installed from Ubuntu Snaps, and on 22.04 there's currently
# an issue where FF lacks access to auto-create a profile, so it hangs.
# However, 20.04 is long-term support (LTS) until 2025: https://wiki.ubuntu.com/Releases
steps:
- name: "Install framebuffer (xvfb), Firefox and Chromium"
run: |
sudo apt-get update
sudo apt-get install chromium-browser firefox xvfb
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: "Install JS dependencies"
run: npm ci
- name: "Run JS tests"
run: xvfb-run npm test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
node_modules
demo/node_modules
demo/libs
tests/unit/coverage
tests/dist
/dist
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tests/unit/coverage
tests/dist
*.yml
dist/
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 2.0.1
# HEAD

- **js:** Migrate JS tests to jasmine-browser-runner (#40).

## Bug Fixes
# 2.0.1

- **js:** Update ESLint config to enforce common rules (#13).
- **js:** Transpile code to ES5 before publishing (#12).
Expand All @@ -9,7 +11,5 @@

# 2.0.0

## Bug Fixes

- **js:** Remove `Mozilla` JS namespace from library (#4).
- **docs:** Update docs to have info about publishing to NPM
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[readme]: https://github.commozmeao/trafficcop/blob/master/README.md
[changelog]: https://github.com/mozmeao/trafficcop/blob/master/CHANGELOG.md
[webpack]: https://webpack.js.org/
[karma]: http://karma-runner.github.io/latest/index.html
[jasmine-browser-runner]: https://jasmine.github.io/setup/browser.html
[jasmine]: https://jasmine.github.io/

# Building the NPM package
Expand All @@ -30,7 +30,7 @@ This will install dependencies, lint JS files, and then build the package conten

# Running tests

To perform the package build process above and then run front-end JS tests using Karma Test Runner[karma] and Jasmine[jasmine] against the processed files:
To perform the package build process above and then run front-end JS tests using Jasmine[jasmine] and Jasmine Browser Runner[jasmine-browser-runner] against the processed files:

```
npm run test
Expand Down
Loading

0 comments on commit e43de00

Please sign in to comment.