Files
react-native-devtools-frontend/scripts/eslint_rules/tests/no_repeated_tests_test.js
T
Peter Marshall f8f4ea4e9f tests: Add a lint check for it.repeat()
We don't want these accidentally committed.

Bug: 1101782
Change-Id: I67a820bbaa6b8a8d1cb4a1a6afdb29bc8dacdc5e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2354107
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2020-08-17 08:04:25 +00:00

50 lines
1.3 KiB
JavaScript

// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
const rule = require('../lib/no_repeated_tests.js');
const ruleTester = new (require('eslint').RuleTester)({
parserOptions: {ecmaVersion: 9, sourceType: 'module'},
});
ruleTester.run('no_repeated_tests', rule, {
valid: [
{
code: `import {describe, it} from '../../shared/mocha-extensions.js';
describe('e2e-test', async () => {
it('normal test', async () => {
});
});
`,
filename: 'test/e2e/folder/file.ts',
},
],
invalid: [
{
code: `import {describe, it} from '../../shared/mocha-extensions.js';
describe('e2e-test', async () => {
it.repeat(5, 'with repeat#', async () => {
});
});
`,
filename: 'test/e2e/folder/file.ts',
errors: [{message: 'Unexpected repeated mocha test'}],
},
{
code: `import {describe, it} from '../../shared/mocha-extensions.js';
describe('e2e-test', async () => {
it.repeat('forgot the repeat#', async () => {
});
});
`,
filename: 'test/e2e/folder/file.ts',
errors: [{message: 'Unexpected repeated mocha test'}],
},
]
});