Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rules): add .concurrent support (#498) #502

Merged
merged 6 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/rules/__tests__/consistent-test-it.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ ruleTester.run('consistent-test-it with fn=test', rule, {
code: 'test.skip("foo")',
options: [{ fn: TestCaseName.test }],
},
{
code: 'test.concurrent("foo")',
options: [{ fn: TestCaseName.test }],
},
{
code: 'xtest("foo")',
options: [{ fn: TestCaseName.test }],
Expand Down Expand Up @@ -90,6 +94,20 @@ ruleTester.run('consistent-test-it with fn=test', rule, {
],
output: 'test.skip("foo")',
},
{
code: 'it.concurrent("foo")',
options: [{ fn: TestCaseName.test }],
errors: [
{
messageId: 'consistentMethod',
data: {
testKeyword: TestCaseName.test,
oppositeTestKeyword: TestCaseName.it,
},
},
],
output: 'test.concurrent("foo")',
},
{
code: 'it.only("foo")',
options: [{ fn: TestCaseName.test }],
Expand Down Expand Up @@ -143,6 +161,10 @@ ruleTester.run('consistent-test-it with fn=it', rule, {
code: 'it.skip("foo")',
options: [{ fn: TestCaseName.it }],
},
{
code: 'it.concurrent("foo")',
options: [{ fn: TestCaseName.it }],
},
{
code: 'describe("suite", () => { it("foo") })',
options: [{ fn: TestCaseName.it }],
Expand Down Expand Up @@ -191,6 +213,20 @@ ruleTester.run('consistent-test-it with fn=it', rule, {
],
output: 'it.skip("foo")',
},
{
code: 'test.concurrent("foo")',
options: [{ fn: TestCaseName.it }],
errors: [
{
messageId: 'consistentMethod',
data: {
testKeyword: TestCaseName.it,
oppositeTestKeyword: TestCaseName.test,
},
},
],
output: 'it.concurrent("foo")',
},
{
code: 'test.only("foo")',
options: [{ fn: TestCaseName.it }],
Expand Down Expand Up @@ -236,6 +272,10 @@ ruleTester.run('consistent-test-it with fn=test and withinDescribe=it ', rule, {
code: 'test.skip("foo")',
options: [{ fn: TestCaseName.test, withinDescribe: TestCaseName.it }],
},
{
code: 'test.concurrent("foo")',
options: [{ fn: TestCaseName.test, withinDescribe: TestCaseName.it }],
},
{
code: 'xtest("foo")',
options: [{ fn: TestCaseName.test, withinDescribe: TestCaseName.it }],
Expand Down Expand Up @@ -302,6 +342,20 @@ ruleTester.run('consistent-test-it with fn=test and withinDescribe=it ', rule, {
],
output: 'describe("suite", () => { it.skip("foo") })',
},
{
code: 'describe("suite", () => { test.concurrent("foo") })',
options: [{ fn: TestCaseName.test, withinDescribe: TestCaseName.it }],
errors: [
{
messageId: 'consistentMethodWithinDescribe',
data: {
testKeywordWithinDescribe: TestCaseName.it,
oppositeTestKeyword: TestCaseName.test,
},
},
],
output: 'describe("suite", () => { it.concurrent("foo") })',
},
],
});

Expand All @@ -319,6 +373,10 @@ ruleTester.run('consistent-test-it with fn=it and withinDescribe=test ', rule, {
code: 'it.skip("foo")',
options: [{ fn: TestCaseName.it, withinDescribe: TestCaseName.test }],
},
{
code: 'it.concurrent("foo")',
options: [{ fn: TestCaseName.it, withinDescribe: TestCaseName.test }],
},
{
code: 'xit("foo")',
options: [{ fn: TestCaseName.it, withinDescribe: TestCaseName.test }],
Expand Down Expand Up @@ -385,6 +443,20 @@ ruleTester.run('consistent-test-it with fn=it and withinDescribe=test ', rule, {
],
output: 'describe("suite", () => { test.skip("foo") })',
},
{
code: 'describe("suite", () => { it.concurrent("foo") })',
options: [{ fn: TestCaseName.it, withinDescribe: TestCaseName.test }],
errors: [
{
messageId: 'consistentMethodWithinDescribe',
data: {
testKeywordWithinDescribe: TestCaseName.test,
oppositeTestKeyword: TestCaseName.it,
},
},
],
output: 'describe("suite", () => { test.concurrent("foo") })',
},
],
});

Expand Down
10 changes: 10 additions & 0 deletions src/rules/__tests__/no-commented-out-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ ruleTester.run('no-commented-out-tests', rule, {
'it("foo", function () {})',
'describe.only("foo", function () {})',
'it.only("foo", function () {})',
'it.concurrent("foo", function () {})',
'test("foo", function () {})',
'test.only("foo", function () {})',
'test.concurrent("foo", function () {})',
'var appliedSkip = describe.skip; appliedSkip.apply(describe)',
'var calledSkip = it.skip; calledSkip.call(it)',
'({ f: function () {} }).f()',
Expand Down Expand Up @@ -80,6 +82,10 @@ ruleTester.run('no-commented-out-tests', rule, {
code: '// it.only("foo", function () {})',
errors: [{ messageId: 'commentedTests', column: 1, line: 1 }],
},
{
code: '// it.concurrent("foo", function () {})',
errors: [{ messageId: 'commentedTests', column: 1, line: 1 }],
},
{
code: '// it["skip"]("foo", function () {})',
errors: [{ messageId: 'commentedTests', column: 1, line: 1 }],
Expand All @@ -88,6 +94,10 @@ ruleTester.run('no-commented-out-tests', rule, {
code: '// test.skip("foo", function () {})',
errors: [{ messageId: 'commentedTests', column: 1, line: 1 }],
},
{
code: '// test.concurrent("foo", function () {})',
errors: [{ messageId: 'commentedTests', column: 1, line: 1 }],
},
{
code: '// test["skip"]("foo", function () {})',
errors: [{ messageId: 'commentedTests', column: 1, line: 1 }],
Expand Down
10 changes: 10 additions & 0 deletions src/rules/__tests__/no-disabled-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ ruleTester.run('no-disabled-tests', rule, {
'it("foo", function () {})',
'describe.only("foo", function () {})',
'it.only("foo", function () {})',
'it.concurrent("foo", function () {})',
'test("foo", function () {})',
'test.only("foo", function () {})',
'test.concurrent("foo", function () {})',
'describe[`${"skip"}`]("foo", function () {})',
'var appliedSkip = describe.skip; appliedSkip.apply(describe)',
'var calledSkip = it.skip; calledSkip.call(it)',
Expand Down Expand Up @@ -73,6 +75,10 @@ ruleTester.run('no-disabled-tests', rule, {
code: 'it.skip("foo", function () {})',
errors: [{ messageId: 'skippedTest', column: 1, line: 1 }],
},
{
code: 'it.concurrent.skip("foo", function () {})',
errors: [{ messageId: 'skippedTest', column: 1, line: 1 }],
},
{
code: 'it["skip"]("foo", function () {})',
errors: [{ messageId: 'skippedTest', column: 1, line: 1 }],
Expand All @@ -81,6 +87,10 @@ ruleTester.run('no-disabled-tests', rule, {
code: 'test.skip("foo", function () {})',
errors: [{ messageId: 'skippedTest', column: 1, line: 1 }],
},
{
code: 'test.concurrent.skip("foo", function () {})',
errors: [{ messageId: 'skippedTest', column: 1, line: 1 }],
},
{
code: 'test["skip"]("foo", function () {})',
errors: [{ messageId: 'skippedTest', column: 1, line: 1 }],
Expand Down
11 changes: 11 additions & 0 deletions src/rules/__tests__/no-focused-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ ruleTester.run('no-focused-tests', rule, {
'it()',
'describe.skip()',
'it.skip()',
'it.concurrent.skip()',
'test()',
'test.skip()',
'test.concurrent.skip()',
'var appliedOnly = describe.only; appliedOnly.apply(describe)',
'var calledOnly = it.only; calledOnly.call(it)',
'it.each()()',
'it.each`table`()',
'test.each()()',
'test.each`table`()',
'test.concurrent()',
],

invalid: [
Expand All @@ -46,6 +49,10 @@ ruleTester.run('no-focused-tests', rule, {
code: 'it.only()',
errors: [{ messageId: 'focusedTest', column: 4, line: 1 }],
},
{
code: 'it.concurrent.only()',
errors: [{ messageId: 'focusedTest', column: 4, line: 1 }],
},
{
code: 'it.only.each()',
errors: [{ messageId: 'focusedTest', column: 4, line: 1 }],
Expand All @@ -62,6 +69,10 @@ ruleTester.run('no-focused-tests', rule, {
code: 'test.only()',
errors: [{ messageId: 'focusedTest', column: 6, line: 1 }],
},
{
code: 'test.concurrent.only()',
errors: [{ messageId: 'focusedTest', column: 6, line: 1 }],
},
{
code: 'test.only.each()',
errors: [{ messageId: 'focusedTest', column: 6, line: 1 }],
Expand Down
33 changes: 33 additions & 0 deletions src/rules/__tests__/no-identical-title.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,22 @@ ruleTester.run('no-identical-title', rule, {
'});',
].join('\n'),
['it("it1", function() {});', 'it("it2", function() {});'].join('\n'),
[
'it.concurrent("it1", function() {});',
'it.concurrent("it2", function() {});',
].join('\n'),
['it.only("it1", function() {});', 'it("it2", function() {});'].join('\n'),
['it.only("it1", function() {});', 'it.only("it2", function() {});'].join(
'\n',
),
[
'it.concurrent.only("it1", function() {});',
'it.concurrent("it2", function() {});',
].join('\n'),
[
'it.concurrent.only("it1", function() {});',
'it.concurrent.only("it2", function() {});',
].join('\n'),
['describe("title", function() {});', 'it("title", function() {});'].join(
'\n',
),
Expand Down Expand Up @@ -118,13 +130,27 @@ ruleTester.run('no-identical-title', rule, {
),
errors: [{ messageId: 'multipleTestTitle', column: 4, line: 2 }],
},
{
code: [
'it.concurrent("it1", function() {});',
'it.concurrent("it1", function() {});',
].join('\n'),
errors: [{ messageId: 'multipleTestTitle', column: 15, line: 2 }],
},
{
code: [
'it.only("it1", function() {});',
'it("it1", function() {});',
].join('\n'),
errors: [{ messageId: 'multipleTestTitle', column: 4, line: 2 }],
},
{
code: [
'it.concurrent.only("it1", function() {});',
'it.concurrent("it1", function() {});',
].join('\n'),
errors: [{ messageId: 'multipleTestTitle', column: 15, line: 2 }],
},
{
code: ['fit("it1", function() {});', 'it("it1", function() {});'].join(
'\n',
Expand All @@ -138,6 +164,13 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [{ messageId: 'multipleTestTitle', column: 9, line: 2 }],
},
{
code: [
'it.concurrent.only("it1", function() {});',
'it.concurrent.only("it1", function() {});',
].join('\n'),
errors: [{ messageId: 'multipleTestTitle', column: 20, line: 2 }],
},
{
code: [
'describe("describe1", function() {});',
Expand Down
34 changes: 32 additions & 2 deletions src/rules/__tests__/no-if.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ ruleTester.run('no-if', rule, {
},
],
},
{
code: `it.concurrent.skip('foo', () => {
if('bar') {}
})`,
errors: [
{
messageId: 'noIf',
},
],
},
{
code: `it.only('foo', () => {
if('bar') {}
Expand All @@ -200,6 +210,16 @@ ruleTester.run('no-if', rule, {
},
],
},
{
code: `it.concurrent.only('foo', () => {
if('bar') {}
})`,
errors: [
{
messageId: 'noIf',
},
],
},
{
code: `xit('foo', () => {
if('bar') {}
Expand All @@ -220,6 +240,16 @@ ruleTester.run('no-if', rule, {
},
],
},
{
code: `fit.concurrent('foo', () => {
if('bar') {}
})`,
errors: [
{
messageId: 'noIf',
},
],
},
{
code: `test('foo', () => {
if('bar') {}
Expand All @@ -231,7 +261,7 @@ ruleTester.run('no-if', rule, {
],
},
{
code: `test.skip('foo', () => {
code: `test.concurrent.skip('foo', () => {
if('bar') {}
})`,
errors: [
Expand All @@ -241,7 +271,7 @@ ruleTester.run('no-if', rule, {
],
},
{
code: `test.only('foo', () => {
code: `test.concurrent.only('foo', () => {
if('bar') {}
})`,
errors: [
Expand Down
1 change: 1 addition & 0 deletions src/rules/__tests__/no-standalone-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ruleTester.run('no-standalone-expect', rule, {
});
`,
'it.only("an only", value => { expect(value).toBe(true); });',
'it.concurrent("an concurrent", value => { expect(value).toBe(true); });',
'describe.each([1, true])("trues", value => { it("an it", () => expect(value).toBe(true) ); });',
],
invalid: [
Expand Down
Loading