diff --git a/codemods/transformTestUtils.ts b/codemods/transformTestUtils.ts index 70c1c6f8..2fa25dfb 100644 --- a/codemods/transformTestUtils.ts +++ b/codemods/transformTestUtils.ts @@ -1,9 +1,10 @@ import { globbySync } from 'globby' import type { Transform } from 'jscodeshift' import type { TestOptions } from 'jscodeshift/src/testUtils' -import { runInlineTest } from 'jscodeshift/src/testUtils' +import { applyTransform } from 'jscodeshift/src/testUtils' import fs from 'node:fs' import path from 'node:path' +import { EOL } from "node:os"; export const runTransformTest = ( name: string, @@ -35,38 +36,41 @@ export const runTransformTest = ( `${testName}.output${extension}`, ) - const inputFileContent = fs.readFileSync(inputPath, 'utf8') + const inputFileContent = fs + .readFileSync(inputPath, 'utf8') + .trim() - const expectedOutput = fs.readFileSync(outputPath, 'utf8') + const expectedOutput = fs + .readFileSync(outputPath, 'utf8').replace(EOL, '\n') describe(`${testName}${extension}`, () => { it('transforms correctly', () => { - runInlineTest( + const output = applyTransform( transform, {}, { - path: testInputPath, - source: inputFileContent, - }, - expectedOutput, - { - parser, + // path: testInputPath, + source: inputFileContent.replace(EOL, '\n'), }, + { parser }, + ) + expect(output.replace(EOL, '\n')).toBe( + expectedOutput.trim(), ) }) it('is idempotent', () => { - runInlineTest( + const output = applyTransform( transform, {}, { - path: testInputPath, - source: inputFileContent, - }, - expectedOutput, - { - parser, + // path: testInputPath, + source: inputFileContent.replace(EOL, '\n'), }, + { parser }, + ) + expect(output.replace(EOL, '\n')).toBe( + expectedOutput.trim(), ) }) })