Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move snapshot tests to separate files #135

Closed
milahu opened this issue Nov 2, 2022 · 0 comments
Closed

move snapshot tests to separate files #135

milahu opened this issue Nov 2, 2022 · 0 comments

Comments

@milahu
Copy link

milahu commented Nov 2, 2022

currently we store multiple test cases together

  it("transforms a to b", () => {
    expect(
      t(`
        a
      `)
    ).toBe(
      format(`
        b
      `)
    );
  });
  it("transforms c to d", () => {
    expect(
      t(`
        c
      `)
    ).toBe(
      format(`
        d
      `)
    );
  });

... for example in packages/codemod/test/transforms/replaceReactUseEffect.test.ts

make this more pretty by storing the test cases in separate files
for example in packages/codemod/test/transforms/replaceReactUseEffect/

transforms a to b.src.ts

a

transforms a to b.out.ts

b

make this more pretty

benefit: pretty git diff

similar issue BuilderIO/mitosis#856

compromise solutions with jest-snapshot ...

expect("a").toMatchSnapshot() // snapshot is stored in __snapshots__/*.snap
expect("a").toMatchInlineSnapshot("b")

→ update snapshots with npx jest -u

https://jestjs.io/docs/snapshot-testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants