1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

Add a bit of documentation on how to run the code coverage (#25783)

This commit is contained in:
Johann-S 2018-03-06 06:35:28 +01:00 committed by XhmikosR
parent e43f97304e
commit fb60a4a986

View file

@ -27,16 +27,20 @@ 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 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) * Each test should follow the project's [JavaScript Code Guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md#js)
## Code coverage
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 ### Example tests
```javascript ```js
// Synchronous test // Synchronous test
QUnit.test('should describe the unit being tested', function (assert) { QUnit.test('should describe the unit being tested', function (assert) {
assert.expect(1) assert.expect(1)
var templateHTML = '<div class="alert alert-danger fade show">' var templateHTML = '<div class="alert alert-danger fade show">' +
+ '<a class="close" href="#" data-dismiss="alert">×</a>' '<a class="close" href="#" data-dismiss="alert">×</a>' +
+ '<p><strong>Template necessary for the test.</p>' '<p><strong>Template necessary for the test.</p>' +
+ '</div>' '</div>'
var $alert = $(templateHTML).appendTo('#qunit-fixture').bootstrapAlert() var $alert = $(templateHTML).appendTo('#qunit-fixture').bootstrapAlert()
$alert.find('.close').trigger('click') $alert.find('.close').trigger('click')