Skip to content

Commit

Permalink
chore: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Jul 1, 2024
1 parent 823887a commit 1034dc0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
11 changes: 8 additions & 3 deletions src/rules/require-hook.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import rule from '../../src/rules/require-hook'
import { runRuleTester, runTSRuleTester } from '../utils/rule-tester'
import {
javascript,
runRuleTester,
runTSRuleTester,
typescript,
} from '../utils/rule-tester'

const messageId = 'useHook'

Expand Down Expand Up @@ -323,7 +328,7 @@ runRuleTester('require-hook', rule, {
runTSRuleTester('require-hook - TypeScript', rule, {
invalid: [
{
code: javascript`
code: typescript`
import { setup } from '../test-utils';
// todo: https:/DefinitelyTyped/DefinitelyTyped/pull/56545
Expand All @@ -343,7 +348,7 @@ runTSRuleTester('require-hook - TypeScript', rule, {
},
],
valid: [
javascript`
typescript`
import { myFn } from '../functions';
// todo: https:/DefinitelyTyped/DefinitelyTyped/pull/56545
Expand Down
34 changes: 19 additions & 15 deletions src/utils/parseFnCall.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dedent from 'dedent'
import { Rule } from 'eslint'
import * as ESTree from 'estree'
import { getStringValue } from './ast'
Expand All @@ -8,7 +7,12 @@ import {
parseFnCallWithReason,
type ResolvedFnWithNode,
} from './parseFnCall'
import { runRuleTester, runTSRuleTester } from './rule-tester'
import {
javascript,
runRuleTester,
runTSRuleTester,
typescript,
} from './rule-tester'

const isNode = (obj: unknown): obj is ESTree.Node => {
if (typeof obj === 'object' && obj !== null) {
Expand Down Expand Up @@ -257,7 +261,7 @@ runRuleTester('expect', rule, {
],
},
{
code: dedent`
code: javascript`
import { expect } from '@playwright/test';
expect(x).toBe(y);
Expand Down Expand Up @@ -287,7 +291,7 @@ runRuleTester('expect', rule, {
],
},
{
code: dedent`
code: javascript`
import { expect } from '@playwright/test';
expect(x).not.toBe(y);
Expand Down Expand Up @@ -347,7 +351,7 @@ runRuleTester('expect', rule, {
errors: [{ column: 11, line: 1, messageId: 'matcher-not-called' }],
},
{
code: dedent`
code: javascript`
import { expect } from '@playwright/test';
expect;
Expand All @@ -363,7 +367,7 @@ runRuleTester('expect', rule, {
],
},
{
code: dedent`
code: javascript`
import { expect } from '@playwright/test';
expect(x).is.toBe(x);
Expand All @@ -375,7 +379,7 @@ runRuleTester('expect', rule, {
errors: [{ column: 1, line: 1, messageId: 'matcher-not-found' }],
},
{
code: dedent`
code: javascript`
import { expect } from '@playwright/test';
expect(x).not.resolves.toBe(x);
Expand Down Expand Up @@ -457,7 +461,7 @@ runRuleTester('test', rule, {
],
},
{
code: dedent`
code: javascript`
test('test full report', {
annotation: [
{ type: 'issue', description: 'https:/microsoft/playwright/issues/23180' },
Expand Down Expand Up @@ -854,7 +858,7 @@ runRuleTester('describe', rule, {
],
},
{
code: dedent`
code: javascript`
test.describe('group', {
tag: '@report',
}, () => {
Expand Down Expand Up @@ -965,7 +969,7 @@ runRuleTester('describe', rule, {
settings: { playwright: { globalAliases: { describe: ['context'] } } },
},
{
code: dedent`
code: javascript`
context("when there is an error", () => {})
describe("when there is an error", () => {})
`,
Expand Down Expand Up @@ -1059,7 +1063,7 @@ runRuleTester('describe', rule, {
runTSRuleTester('typescript', rule, {
invalid: [
{
code: dedent`
code: typescript`
import { test } from '../it-utils';
import { test } from '@playwright/test';
Expand Down Expand Up @@ -1087,7 +1091,7 @@ runTSRuleTester('typescript', rule, {
],
valid: [
{
code: dedent`
code: typescript`
function it(message: string, fn: () => void): void;
function it(cases: unknown[], message: string, fn: () => void): void;
function it(...all: any[]): void {}
Expand All @@ -1096,22 +1100,22 @@ runTSRuleTester('typescript', rule, {
`,
},
{
code: dedent`
code: typescript`
interface it {}
function it(...all: any[]): void {}
it('is not a function', () => {});
`,
},
"it('is not a function', () => {});",
'dedent()',
'typescript()',
'expect.assertions()',
'expect.anything()',
'expect.arrayContaining()',
'expect.objectContaining(expected)',
'expect.not.objectContaining(expected)',
{
code: dedent`
code: typescript`
import { expect } from '@playwright/test';
expect.assertions();
Expand Down

0 comments on commit 1034dc0

Please sign in to comment.