Skip to content

Commit

Permalink
snapshot instead (updated 16:36)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Jan 26, 2025
1 parent 1b23365 commit 63294b2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
50 changes: 50 additions & 0 deletions test/__snapshots__/mmkal-repos.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`lint https://github.com/mmkal/expect-type 1`] = `
"
> [email protected] eslint <div>/expect-type
> eslint --max-warnings 0 "." "--fix" "--max-warnings" "0"
<div>/expect-type/src/branding.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
<div>/expect-type/src/index.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
<div>/expect-type/src/utils.ts
<line>:<col> error 'secret' is assigned a value but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
<div>/expect-type/test/ts-output.ts
<line>:<col> warning Use default import for module \`node:path\` unicorn/import-style
<div>/expect-type/test/types.test.ts
<line>:<col> error Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions
<line>:<col> error Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions
<div>/expect-type/test/usage.test.ts
<line>:<col> error 'A' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
<line>:<col> error 'B' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
<line>:<col> error 'C' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
✖ 9 problems (8 errors, 1 warning)
 ELIFECYCLE  Command failed with exit code 1."
`;
exports[`lint https://github.com/mmkal/trpc-cli 1`] = `
"
<div>/trpc-cli/src/index.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
<line>:<col> error Expected an error object to be thrown @typescript-eslint/only-throw-error
<div>/trpc-cli/src/util.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
✖ 3 problems (3 errors, 0 warnings)
"
`;
19 changes: 15 additions & 4 deletions test/mmkal-repos.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,34 @@ const reposToTest = [
'https://github.com/mmkal/trpc-cli',
]

const ts = Date.now().toString()

for (const repo of reposToTest) {
test(
`lint ${repo}`,
async () => {
const {execa} = await import('execa')
await execa('pnpm', ['build'])
const tmp = path.join(`/tmp/eslint-plugin-mmkal-testing`, Date.now().toString())
const tmp = path.join(`/tmp/eslint-plugin-mmkal-testing`, ts)
fs.mkdirSync(tmp, {recursive: true})
await execa('git', ['clone', repo], {cwd: tmp})
const [cloneName, ...otherFiles] = fs.readdirSync(tmp)
const [cloneName, ...otherFiles] = fs.readdirSync(tmp).filter(f => f === repo.split('/').pop())
const clone = path.join(tmp, cloneName)
expect(otherFiles).toEqual([])
await execa('pnpm', ['install'], {cwd: clone})
await execa(path.join(process.cwd(), 'node_modules', '.bin', 'link'), [process.cwd()], {cwd: clone})
const {all: lint} = await execa('pnpm', ['eslint', '.', '--fix', '--max-warnings', '0'], {cwd: clone})
const {all: lint} = await execa('pnpm', ['eslint', '.', '--fix', '--max-warnings', '0'], {
all: true,
cwd: clone,
reject: false,
})

expect(lint!.toLowerCase()).not.toContain('error')
const snapshot = lint
.replaceAll(tmp, '<dir>')
.replaceAll('/private<dir>/', '<dir>/')
.replaceAll(ts, '<timestamp>')
.replaceAll(/\d+:\d+/g, '<line>:<col>')
expect(snapshot).toMatchSnapshot()

Check failure on line 37 in test/mmkal-repos.test.ts

View workflow job for this annotation

GitHub Actions / test

test/mmkal-repos.test.ts > lint https://github.com/mmkal/expect-type

Error: Snapshot `lint https://github.com/mmkal/expect-type 1` mismatched - Expected + Received @@ -1,29 +1,29 @@ " - > [email protected] eslint <div>/expect-type + > [email protected] eslint <dir>/expect-type > eslint --max-warnings 0 "." "--fix" "--max-warnings" "0" - <div>/expect-type/src/branding.ts + <dir>/expect-type/src/branding.ts <line>:<col> error The `Function` type accepts any function-like value. Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type - <div>/expect-type/src/index.ts + <dir>/expect-type/src/index.ts <line>:<col> error The `Function` type accepts any function-like value. Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type - <div>/expect-type/src/utils.ts + <dir>/expect-type/src/utils.ts <line>:<col> error 'secret' is assigned a value but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars - <div>/expect-type/test/ts-output.ts + <dir>/expect-type/test/ts-output.ts <line>:<col> warning Use default import for module `node:path` unicorn/import-style - <div>/expect-type/test/types.test.ts + <dir>/expect-type/test/types.test.ts <line>:<col> error Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions <line>:<col> error Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions - <div>/expect-type/test/usage.test.ts + <dir>/expect-type/test/usage.test.ts <line>:<col> error 'A' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars <line>:<col> error 'B' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars <line>:<col> error 'C' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars ✖ 9 problems (8 errors, 1 warning) ❯ test.timeout test/mmkal-repos.test.ts:37:24

Check failure on line 37 in test/mmkal-repos.test.ts

View workflow job for this annotation

GitHub Actions / test

test/mmkal-repos.test.ts > lint https://github.com/mmkal/trpc-cli

Error: Snapshot `lint https://github.com/mmkal/trpc-cli 1` mismatched - Expected + Received " - <div>/trpc-cli/src/index.ts + <dir>/trpc-cli/src/index.ts <line>:<col> error The `Function` type accepts any function-like value. Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type <line>:<col> error Expected an error object to be thrown @typescript-eslint/only-throw-error - <div>/trpc-cli/src/util.ts + <dir>/trpc-cli/src/util.ts <line>:<col> error The `Function` type accepts any function-like value. Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type ✖ 3 problems (3 errors, 0 warnings) " ❯ test.timeout test/mmkal-repos.test.ts:37:24
},
{timeout: 30_000},
)
Expand Down

0 comments on commit 63294b2

Please sign in to comment.