Skip to content

Commit 63d42c2

Browse files
author
Kent C. Dodds
committed
chore: fix eslint issues
1 parent 523fc9a commit 63d42c2

File tree

2 files changed

+38
-50
lines changed

2 files changed

+38
-50
lines changed

src/__tests__/index.js

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,15 @@ test('can get a code and output fixture that is an absolute path', async () => {
245245
outputFixture: getFixturePath('outure1.js'),
246246
},
247247
]
248-
try {
249-
await runPluginTester(getOptions({tests}))
250-
} catch (error) {
251-
const actual = getFixtureContents('fixture1.js')
252-
const expected = getFixtureContents('outure1.js')
253-
expect(error).toMatchObject({
254-
name: expect.stringMatching(/AssertionError/),
255-
message: 'Output is incorrect.',
256-
actual,
257-
expected,
258-
})
259-
}
248+
const error = await runPluginTester(getOptions({tests})).catch(e => e)
249+
const actual = getFixtureContents('fixture1.js')
250+
const expected = getFixtureContents('outure1.js')
251+
expect(error).toMatchObject({
252+
name: expect.stringMatching(/AssertionError/),
253+
message: 'Output is incorrect.',
254+
actual,
255+
expected,
256+
})
260257
})
261258

262259
test('can pass with fixture and outputFixture', async () => {
@@ -283,18 +280,17 @@ test('can resolve a fixture with the filename option', async () => {
283280
outputFixture: 'fixtures/outure1.js',
284281
},
285282
]
286-
try {
287-
await runPluginTester(getOptions({filename: __filename, tests}))
288-
} catch (error) {
289-
const actual = getFixtureContents('fixture1.js')
290-
const expected = getFixtureContents('outure1.js')
291-
expect(error).toMatchObject({
292-
name: expect.stringMatching(/AssertionError/),
293-
message: 'Output is incorrect.',
294-
actual,
295-
expected,
296-
})
297-
}
283+
const error = await runPluginTester(
284+
getOptions({filename: __filename, tests}),
285+
).catch(e => e)
286+
const actual = getFixtureContents('fixture1.js')
287+
const expected = getFixtureContents('outure1.js')
288+
expect(error).toMatchObject({
289+
name: expect.stringMatching(/AssertionError/),
290+
message: 'Output is incorrect.',
291+
actual,
292+
expected,
293+
})
298294
})
299295

300296
test('can pass tests in fixtures relative to the filename', async () => {
@@ -323,17 +319,14 @@ test('can pass tests in fixtures relative to the filename', async () => {
323319
})
324320

325321
test('can fail tests in fixtures at an absolute path', async () => {
326-
try {
327-
await runPluginTester(
328-
getOptions({
329-
plugin: identifierReversePlugin,
330-
tests: null,
331-
fixtures: getFixturePath('failing-fixtures'),
332-
}),
333-
)
334-
} catch (error) {
335-
expect(error.message).toMatchSnapshot()
336-
}
322+
const error = await runPluginTester(
323+
getOptions({
324+
plugin: identifierReversePlugin,
325+
tests: null,
326+
fixtures: getFixturePath('failing-fixtures'),
327+
}),
328+
).catch(e => e)
329+
expect(error.message).toMatchSnapshot()
337330
})
338331

339332
test('creates output file for new tests', async () => {
@@ -347,19 +340,10 @@ test('creates output file for new tests', async () => {
347340

348341
const calls = writeFileSyncSpy.mock.calls[0]
349342
const outputMatch = /(\/|\\)output\.(j|t)sx?$/
350-
if (calls[0].endsWith('.jsx')) {
351-
expect(calls).toEqual([
352-
expect.stringMatching(outputMatch),
353-
'export default <div></div>;',
354-
])
355-
} else if (calls[0].endsWith('.tsx')) {
356-
expect(calls).toEqual([
357-
expect.stringMatching(outputMatch),
358-
'export default <div></div> as any;',
359-
])
360-
} else {
361-
expect(calls).toEqual([expect.stringMatching(outputMatch), "'use strict';"])
362-
}
343+
expect(calls).toEqual([
344+
expect.stringMatching(outputMatch),
345+
'export default <div></div>;',
346+
])
363347
})
364348

365349
test('uses the fixture filename in babelOptions', async () => {

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ function getPluginName(plugin, babel) {
458458

459459
/*
460460
eslint
461-
complexity: "off",
462-
jest/valid-describe: "off"
461+
complexity: off,
462+
jest/valid-describe: off,
463+
jest/no-if: off,
464+
jest/valid-title: off,
465+
jest/no-export: off,
466+
jest/no-try-expect: off,
463467
*/

0 commit comments

Comments
 (0)