1
- import dedent from 'dedent'
2
1
import { Rule } from 'eslint'
3
2
import * as ESTree from 'estree'
4
3
import { getStringValue } from './ast'
@@ -8,7 +7,12 @@ import {
8
7
parseFnCallWithReason ,
9
8
type ResolvedFnWithNode ,
10
9
} from './parseFnCall'
11
- import { runRuleTester , runTSRuleTester } from './rule-tester'
10
+ import {
11
+ javascript ,
12
+ runRuleTester ,
13
+ runTSRuleTester ,
14
+ typescript ,
15
+ } from './rule-tester'
12
16
13
17
const isNode = ( obj : unknown ) : obj is ESTree . Node => {
14
18
if ( typeof obj === 'object' && obj !== null ) {
@@ -257,7 +261,7 @@ runRuleTester('expect', rule, {
257
261
] ,
258
262
} ,
259
263
{
260
- code : dedent `
264
+ code : javascript `
261
265
import { expect } from '@playwright/test';
262
266
263
267
expect(x).toBe(y);
@@ -287,7 +291,7 @@ runRuleTester('expect', rule, {
287
291
] ,
288
292
} ,
289
293
{
290
- code : dedent `
294
+ code : javascript `
291
295
import { expect } from '@playwright/test';
292
296
293
297
expect(x).not.toBe(y);
@@ -347,7 +351,7 @@ runRuleTester('expect', rule, {
347
351
errors : [ { column : 11 , line : 1 , messageId : 'matcher-not-called' } ] ,
348
352
} ,
349
353
{
350
- code : dedent `
354
+ code : javascript `
351
355
import { expect } from '@playwright/test';
352
356
353
357
expect;
@@ -363,7 +367,7 @@ runRuleTester('expect', rule, {
363
367
] ,
364
368
} ,
365
369
{
366
- code : dedent `
370
+ code : javascript `
367
371
import { expect } from '@playwright/test';
368
372
369
373
expect(x).is.toBe(x);
@@ -375,7 +379,7 @@ runRuleTester('expect', rule, {
375
379
errors : [ { column : 1 , line : 1 , messageId : 'matcher-not-found' } ] ,
376
380
} ,
377
381
{
378
- code : dedent `
382
+ code : javascript `
379
383
import { expect } from '@playwright/test';
380
384
381
385
expect(x).not.resolves.toBe(x);
@@ -457,7 +461,7 @@ runRuleTester('test', rule, {
457
461
] ,
458
462
} ,
459
463
{
460
- code : dedent `
464
+ code : javascript `
461
465
test('test full report', {
462
466
annotation: [
463
467
{ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/23180' },
@@ -854,7 +858,7 @@ runRuleTester('describe', rule, {
854
858
] ,
855
859
} ,
856
860
{
857
- code : dedent `
861
+ code : javascript `
858
862
test.describe('group', {
859
863
tag: '@report',
860
864
}, () => {
@@ -965,7 +969,7 @@ runRuleTester('describe', rule, {
965
969
settings : { playwright : { globalAliases : { describe : [ 'context' ] } } } ,
966
970
} ,
967
971
{
968
- code : dedent `
972
+ code : javascript `
969
973
context("when there is an error", () => {})
970
974
describe("when there is an error", () => {})
971
975
` ,
@@ -1059,7 +1063,7 @@ runRuleTester('describe', rule, {
1059
1063
runTSRuleTester ( 'typescript' , rule , {
1060
1064
invalid : [
1061
1065
{
1062
- code : dedent `
1066
+ code : typescript `
1063
1067
import { test } from '../it-utils';
1064
1068
import { test } from '@playwright/test';
1065
1069
@@ -1087,7 +1091,7 @@ runTSRuleTester('typescript', rule, {
1087
1091
] ,
1088
1092
valid : [
1089
1093
{
1090
- code : dedent `
1094
+ code : typescript `
1091
1095
function it(message: string, fn: () => void): void;
1092
1096
function it(cases: unknown[], message: string, fn: () => void): void;
1093
1097
function it(...all: any[]): void {}
@@ -1096,22 +1100,22 @@ runTSRuleTester('typescript', rule, {
1096
1100
` ,
1097
1101
} ,
1098
1102
{
1099
- code : dedent `
1103
+ code : typescript `
1100
1104
interface it {}
1101
1105
function it(...all: any[]): void {}
1102
1106
1103
1107
it('is not a function', () => {});
1104
1108
` ,
1105
1109
} ,
1106
1110
"it('is not a function', () => {});" ,
1107
- 'dedent ()' ,
1111
+ 'typescript ()' ,
1108
1112
'expect.assertions()' ,
1109
1113
'expect.anything()' ,
1110
1114
'expect.arrayContaining()' ,
1111
1115
'expect.objectContaining(expected)' ,
1112
1116
'expect.not.objectContaining(expected)' ,
1113
1117
{
1114
- code : dedent `
1118
+ code : typescript `
1115
1119
import { expect } from '@playwright/test';
1116
1120
1117
1121
expect.assertions();
0 commit comments