From fda410dc98894a86674742a7026841589657793b Mon Sep 17 00:00:00 2001 From: Johann-S Date: Mon, 5 Mar 2018 11:49:51 +0100 Subject: [PATCH 1/3] Add a bit of documentation on how to run the code coverage --- js/tests/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/tests/README.md b/js/tests/README.md index 88c35be40258..792778bed669 100644 --- a/js/tests/README.md +++ b/js/tests/README.md @@ -27,6 +27,16 @@ To run the unit test suite via a real web browser, open `index.html` in the brow * Each test should begin with [`assert.expect`](https://api.qunitjs.com/assert/expect/) to ensure that the expected assertions are run. * Each test should follow the project's [JavaScript Code Guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md#js) +## Code coverage + +Currently we try to ensure at least 80% of code coverage in our JS files. + +So to be use your changes will be compliant with that limit you can run the following command `npm run js-compile && npm run js-test` +and open this file : `js/coverage/lcov-report/index.html`. + +You'll see the code coverage for each of our plugins, you can see more details when you select a plugin and ensure your change is +fully covered by a unit test. + ### Example tests ```javascript From e85ff10f506eaf93216d71267e54954fd942bc5d Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 5 Mar 2018 14:48:31 +0200 Subject: [PATCH 2/3] Update README.md --- js/tests/README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/js/tests/README.md b/js/tests/README.md index 792778bed669..d9752bad6e20 100644 --- a/js/tests/README.md +++ b/js/tests/README.md @@ -29,24 +29,23 @@ To run the unit test suite via a real web browser, open `index.html` in the brow ## Code coverage -Currently we try to ensure at least 80% of code coverage in our JS files. +Currently, we try to make sure at least 80% of code is covered by tests. -So to be use your changes will be compliant with that limit you can run the following command `npm run js-compile && npm run js-test` -and open this file : `js/coverage/lcov-report/index.html`. +So, to be sure your changes are compliant with this limit, you can run `npm run js-compile && npm run js-test` and open the file in `js/coverage/lcov-report/index.html`. -You'll see the code coverage for each of our plugins, you can see more details when you select a plugin and ensure your change is +You'll see the code coverage for each of our plugins, you can see more details when you select a plugin and make sure your change is fully covered by a unit test. ### Example tests -```javascript +```js // Synchronous test QUnit.test('should describe the unit being tested', function (assert) { assert.expect(1) - var templateHTML = '
' - + '×' - + '

Template necessary for the test.

' - + '
' + var templateHTML = '
' + + '×' + + '

Template necessary for the test.

' + + '
' var $alert = $(templateHTML).appendTo('#qunit-fixture').bootstrapAlert() $alert.find('.close').trigger('click') From 68efb709b8f5b1bf1f664211f0ff8215476c4804 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 5 Mar 2018 20:45:56 -0800 Subject: [PATCH 3/3] copyediting --- js/tests/README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/js/tests/README.md b/js/tests/README.md index d9752bad6e20..23c5ff39df54 100644 --- a/js/tests/README.md +++ b/js/tests/README.md @@ -29,12 +29,7 @@ To run the unit test suite via a real web browser, open `index.html` in the brow ## Code coverage -Currently, we try to make sure at least 80% of code is covered by tests. - -So, to be sure your changes are compliant with this limit, you can run `npm run js-compile && npm run js-test` and open the file in `js/coverage/lcov-report/index.html`. - -You'll see the code coverage for each of our plugins, you can see more details when you select a plugin and make sure your change is -fully covered by a unit test. +Currently we're aiming for at least 80% test coverage for our code. To ensure your changes meet or exceed this limit, run `npm run js-compile && npm run js-test` and open the file in `js/coverage/lcov-report/index.html` to see the code coverage for each plugin. See more details when you select a plugin and ensure your change is fully covered by unit tests. ### Example tests