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

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 992 bytes
Line 
1# Disallow using `exports` in files containing tests (`no-export`)
2
3Prevents using `exports` if a file has one or more tests in it.
4
5## Rule Details
6
7This rule aims to eliminate duplicate runs of tests by exporting things from
8test files. If you import from a test file, then all the tests in that file will
9be run in each imported instance, so bottom line, don't export from a test, but
10instead move helper functions into a separate file when they need to be shared
11across tests.
12
13Examples of **incorrect** code for this rule:
14
15```js
16export function myHelper() {}
17
18module.exports = function () {};
19
20module.exports = {
21 something: 'that should be moved to a non-test file',
22};
23
24describe('a test', () => {
25 expect(1).toBe(1);
26});
27```
28
29Examples of **correct** code for this rule:
30
31```js
32function myHelper() {}
33
34const myThing = {
35 something: 'that can live here',
36};
37
38describe('a test', () => {
39 expect(1).toBe(1);
40});
41```
42
43## When Not To Use It
44
45Don't use this rule on non-jest test files.
Note: See TracBrowser for help on using the repository browser.