source: frontend/node_modules/eslint-plugin-jest/docs/rules/no-jasmine-globals.md

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
Line 
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
5environment. Most functionality offered by Jasmine has been ported to Jest, and
6the Jasmine globals will stop working in the future. Developers should therefore
7migrate to Jest's documented API instead of relying on the undocumented Jasmine
8API.
9
10### Rule details
11
12This rule reports on any usage of Jasmine globals which is not ported to Jest,
13and suggests alternative from Jest's own API.
14
15### Default configuration
16
17The following patterns are considered warnings:
18
19```js
20jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
21
22test('my test', () => {
23 pending();
24});
25
26test('my test', () => {
27 fail();
28});
29
30test('my test', () => {
31 spyOn(some, 'object');
32});
33
34test('my test', () => {
35 jasmine.createSpy();
36});
37
38test('my test', () => {
39 expect('foo').toEqual(jasmine.anything());
40});
41```
42
43The following patterns would not be considered warnings:
44
45```js
46jest.setTimeout(5000);
47
48test('my test', () => {
49 jest.spyOn(some, 'object');
50});
51
52test('my test', () => {
53 jest.fn();
54});
55
56test('my test', () => {
57 expect('foo').toEqual(expect.anything());
58});
59```
Note: See TracBrowser for help on using the repository browser.