|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [9af201e] | 1 | # Disallow Jasmine globals (`no-jasmine-globals`)
|
|---|
| 2 |
|
|---|
| 3 | `jest` uses `jasmine` as a test runner. A side effect of this is that both a
|
|---|
| 4 | `jasmine` object, and some jasmine-specific globals, are exposed to the test
|
|---|
| 5 | environment. Most functionality offered by Jasmine has been ported to Jest, and
|
|---|
| 6 | the Jasmine globals will stop working in the future. Developers should therefore
|
|---|
| 7 | migrate to Jest's documented API instead of relying on the undocumented Jasmine
|
|---|
| 8 | API.
|
|---|
| 9 |
|
|---|
| 10 | ### Rule details
|
|---|
| 11 |
|
|---|
| 12 | This rule reports on any usage of Jasmine globals which is not ported to Jest,
|
|---|
| 13 | and suggests alternative from Jest's own API.
|
|---|
| 14 |
|
|---|
| 15 | ### Default configuration
|
|---|
| 16 |
|
|---|
| 17 | The following patterns are considered warnings:
|
|---|
| 18 |
|
|---|
| 19 | ```js
|
|---|
| 20 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
|---|
| 21 |
|
|---|
| 22 | test('my test', () => {
|
|---|
| 23 | pending();
|
|---|
| 24 | });
|
|---|
| 25 |
|
|---|
| 26 | test('my test', () => {
|
|---|
| 27 | fail();
|
|---|
| 28 | });
|
|---|
| 29 |
|
|---|
| 30 | test('my test', () => {
|
|---|
| 31 | spyOn(some, 'object');
|
|---|
| 32 | });
|
|---|
| 33 |
|
|---|
| 34 | test('my test', () => {
|
|---|
| 35 | jasmine.createSpy();
|
|---|
| 36 | });
|
|---|
| 37 |
|
|---|
| 38 | test('my test', () => {
|
|---|
| 39 | expect('foo').toEqual(jasmine.anything());
|
|---|
| 40 | });
|
|---|
| 41 | ```
|
|---|
| 42 |
|
|---|
| 43 | The following patterns would not be considered warnings:
|
|---|
| 44 |
|
|---|
| 45 | ```js
|
|---|
| 46 | jest.setTimeout(5000);
|
|---|
| 47 |
|
|---|
| 48 | test('my test', () => {
|
|---|
| 49 | jest.spyOn(some, 'object');
|
|---|
| 50 | });
|
|---|
| 51 |
|
|---|
| 52 | test('my test', () => {
|
|---|
| 53 | jest.fn();
|
|---|
| 54 | });
|
|---|
| 55 |
|
|---|
| 56 | test('my test', () => {
|
|---|
| 57 | expect('foo').toEqual(expect.anything());
|
|---|
| 58 | });
|
|---|
| 59 | ```
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.