web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.5 KiB

  1. # Disallow disabled tests (`no-disabled-tests`)
  2. Jest has a feature that allows you to temporarily mark tests as disabled. This
  3. feature is often helpful while debugging or to create placeholders for future
  4. tests. Before committing changes we may want to check that all tests are
  5. running.
  6. This rule raises a warning about disabled tests.
  7. ## Rule Details
  8. There are a number of ways to disable tests in Jest:
  9. - by appending `.skip` to the test-suite or test-case
  10. - by prepending the test function name with `x`
  11. - by declaring a test with a name but no function body
  12. - by making a call to `pending()` anywhere within the test
  13. The following patterns are considered warnings:
  14. ```js
  15. describe.skip('foo', () => {});
  16. it.skip('foo', () => {});
  17. test.skip('foo', () => {});
  18. describe['skip']('bar', () => {});
  19. it['skip']('bar', () => {});
  20. test['skip']('bar', () => {});
  21. xdescribe('foo', () => {});
  22. xit('foo', () => {});
  23. xtest('foo', () => {});
  24. it('bar');
  25. test('bar');
  26. it('foo', () => {
  27. pending();
  28. });
  29. ```
  30. These patterns would not be considered warnings:
  31. ```js
  32. describe('foo', () => {});
  33. it('foo', () => {});
  34. test('foo', () => {});
  35. describe.only('bar', () => {});
  36. it.only('bar', () => {});
  37. test.only('bar', () => {});
  38. ```
  39. ### Limitations
  40. The plugin looks at the literal function names within test code, so will not
  41. catch more complex examples of disabled tests, such as:
  42. ```js
  43. const testSkip = test.skip;
  44. testSkip('skipped test', () => {});
  45. const myTest = test;
  46. myTest('does not have function body');
  47. ```