Skip to content

Commit 166678d

Browse files
Add jasmine-browser-runner (#13765)
* Add jasmine-browser-runner tests * Replace Karma with Jasmine Browser Runner * Update test npm script * Update jasmine webpack and test commands * Update npm script and documentation * PR revisions * Add package lock
1 parent 235276d commit 166678d

9 files changed

+1215
-1311
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = {
7979
}
8080
},
8181
{
82-
// JS Karma test files.
82+
// JS Jasmine test files.
8383
files: ['tests/unit/**/*.js'],
8484
env: {
8585
es2017: true,
@@ -97,7 +97,7 @@ module.exports = {
9797
files: [
9898
'webpack.config.js',
9999
'webpack.static.config.js',
100-
'tests/unit/karma.conf.js'
100+
'webpack.test.config.js'
101101
],
102102
env: {
103103
node: true,

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ tests/unit/coverage
6060
Thumbs.db
6161
tmp/*
6262
venv
63+
tests/unit/dist/

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static
99
static_build
1010
static_final
1111
venv
12+
tests/unit/dist
1213

1314
# Ignore external JS libraries
1415
media/js/libs/**/

docs/testing.rst

+42-25
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,58 @@ Front-end testing
99
=================
1010

1111
Bedrock runs a suite of front-end `Jasmine`_ behavioral/unit tests, which use
12-
`Karma`_ as a test runner. We also have a suite of functional tests using
12+
`Jasmine Browser Runner`_ as a test runner. We also have a suite of functional tests using
1313
`Selenium`_ and `pytest`_. This allows us to emulate users interacting with a
14-
real browser. All these test suites live in the ``tests`` directory.
14+
real browser. All these test suites live in the ``tests`` directory. To run the tests locally,
15+
you must also first download `geckodriver`_ and `chromedriver`_ and make it available
16+
in your system path. You can alternatively specify the path to geckodriver and chromedriver
17+
using the command line (see the `pytest-selenium documentation`_ for more information).
1518

1619
The ``tests`` directory comprises of:
1720

1821
* ``/functional`` contains pytest tests.
1922
* ``/pages`` contains Python page objects.
20-
* ``/unit`` contains the Jasmine tests and Karma config file.
23+
* ``/unit`` contains the Jasmine tests and Jasmine Browser Runner config file.
2124

2225
Installation
2326
------------
2427

2528
First follow the :ref:`installation instructions for bedrock<install>`, which
2629
will install the dependencies required to run the various front-end test suites.
2730

31+
To download geckodriver and chromedriver and have it ready to run in your system, there are a couple of ways:
2832

29-
Running Jasmine tests using Karma
33+
- Download geckdriver's `latest release`_ and add it to your system path:
34+
35+
.. code-block:: bash
36+
37+
cd /path/to/your/downloaded/files/
38+
mv geckodriver /usr/local/bin/
39+
40+
- If you're on MacOS, download geckodriver directly using Homebrew, which automatically places it in your system path:
41+
42+
.. code-block:: bash
43+
44+
brew install geckodriver
45+
46+
47+
- Download chromedriver's `latest release <https://chromedriver.chromium.org/downloads>`_ and add it to your system path:
48+
49+
.. code-block:: bash
50+
51+
cd /path/to/your/downloaded/files/
52+
mv chromedriver /usr/local/bin/
53+
54+
- If you're on MacOS, download chromedriver directly using Homebrew/Cask, which automatically places it in your system path:
55+
56+
.. code-block:: bash
57+
58+
brew tap homebrew/cask
59+
60+
brew cask install chromedriver
61+
62+
63+
Running Jasmine tests using Jasmine Browser Runner
3064
---------------------------------
3165

3266
To perform a single run of the Jasmine test suite using Firefox and Chrome,
@@ -49,7 +83,7 @@ run:
4983

5084
.. code-block:: bash
5185
52-
$ npm run karma
86+
$ npm run test
5387
5488
See the `Jasmine`_ documentation for tips on how to write JS behavioral or unit
5589
tests. We also use `Sinon`_ for creating test spies, stubs and mocks.
@@ -62,25 +96,7 @@ Running functional tests
6296
Before running the functional tests, please make sure to follow the bedrock
6397
:ref:`installation docs<install>`, including the database sync that is needed
6498
to pull in external data such as event/blog feeds etc. These are required for
65-
some of the tests to pass. To run the tests using Firefox, you must also first
66-
download `geckodriver`_ and make it available in your system path. You can
67-
alternatively specify the path to geckodriver using the command line (see the
68-
`pytest-selenium documentation`_ for more information).
69-
70-
To download geckodriver and have it ready to run in your system, there are a couple of ways:
71-
72-
- Download its `latest release`_ and add it to your system path:
73-
74-
.. code-block:: bash
75-
76-
cd /path/to/your/downloaded/files/
77-
mv geckodriver /usr/local/bin/
78-
79-
- If you're on MacOS, download it directly using Homebrew, which automatically places it in your system path:
80-
81-
.. code-block:: bash
82-
83-
brew install geckodriver
99+
some of the tests to pass.
84100

85101
To run the full functional test suite against your local bedrock instance in
86102
Mozorg mode:
@@ -320,7 +336,7 @@ These tests and are run as part of the pipeline to ensure that download links co
320336
via product details are well formed and return valid 200 responses.
321337

322338
.. _Jasmine: https://jasmine.github.io/index.html
323-
.. _Karma: https://karma-runner.github.io/
339+
.. _Jasmine Browser Runner: https://jasmine.github.io/setup/browser.html
324340
.. _Sinon: http://sinonjs.org/
325341
.. _Selenium: http://docs.seleniumhq.org/
326342
.. _pytest: http://pytest.org/latest/
@@ -337,3 +353,4 @@ via product details are well formed and return valid 200 responses.
337353
.. _Basket: https://github.com/mozilla/basket
338354
.. _geckodriver: https://github.com/mozilla/geckodriver/releases/latest
339355
.. _latest release: https://github.com/mozilla/geckodriver/releases/
356+
.. _chromedriver: https://chromedriver.chromium.org/downloads

0 commit comments

Comments
 (0)