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

toMatchInlineSnapshot confused on imported tests #484

Closed
6 tasks done
holtwick opened this issue Jan 8, 2022 · 1 comment
Closed
6 tasks done

toMatchInlineSnapshot confused on imported tests #484

holtwick opened this issue Jan 8, 2022 · 1 comment

Comments

@holtwick
Copy link

holtwick commented Jan 8, 2022

Describe the bug

If toMatchInlineSnapshot is used in an imported file, vitest gets confused. For toMatchSnaphot will instead be written to a snapshot named after the importing file.

Use case: Have different tests e.g. for adapters (somthing like an API for web, websocket, filesystem, etc.). They should provide the same result for each adapter. Reusing the test result helps reducing code and separate adapter centric stuff from logic stuff.

It works in Jest.

Reproduction

https://stackblitz.com/edit/node-kg1mn9?file=test/suite.test.ts

Run npm test

It will result in strange update. external.ts is not changed.

20220108-091342-capture-holtwick@2x

System Info

System:
    OS: macOS 12.1
    CPU: (8) arm64 Apple M1
    Memory: 86.13 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.3.0 - /opt/homebrew/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.3.0 - /opt/homebrew/bin/npm
  Browsers:
    Edge: 96.0.1054.43
    Firefox: 95.0.2
    Safari: 15.2
    Safari Technology Preview: 15.4

Used Package Manager

pnpm

Validations

@holtwick
Copy link
Author

holtwick commented Jan 10, 2022

I updated the example again, and it seems to fail if describe and it are used via --global option.

https://stackblitz.com/edit/node-h9ghpk?file=test/suite.test.ts

20220110-223537-capture-holtwick@2x

vikunja-bot pushed a commit to go-vikunja/frontend that referenced this issue Jan 10, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [vitest](https://github.com/vitest-dev/vitest) | devDependencies | patch | [`0.0.139` -> `0.0.140`](https://renovatebot.com/diffs/npm/vitest/0.0.139/0.0.140) |

---

### Release Notes

<details>
<summary>vitest-dev/vitest</summary>

### [`v0.0.140`](https://github.com/vitest-dev/vitest/releases/v0.0.140)

[Compare Source](vitest-dev/vitest@v0.0.139...v0.0.140)

##### Bug Fixes

-   inline snapshot if not called inside suite ([6d743c5](vitest-dev/vitest@6d743c5)), closes [#&#8203;484](vitest-dev/vitest#484)
-   **ui:** flex / percentage based layout ([#&#8203;492](vitest-dev/vitest#492)) ([c43ebaf](vitest-dev/vitest@c43ebaf))
-   correctly inline shapshot with properties ([4603ffd](vitest-dev/vitest@4603ffd))
-   mocking is lost with threads: false ([28b97d8](vitest-dev/vitest@28b97d8)), closes [#&#8203;482](vitest-dev/vitest#482)
-   Reflect.get called on non-object ([3c9073a](vitest-dev/vitest@3c9073a)), closes [#&#8203;479](vitest-dev/vitest#479)
-   snapshot ignores indentation ([aff1481](vitest-dev/vitest@aff1481))
-   **ui:** reduce graph container size ([#&#8203;478](vitest-dev/vitest#478)) ([23e1e62](vitest-dev/vitest@23e1e62))

##### Features

-   global setup ([#&#8203;372](vitest-dev/vitest#372)) ([eaa119f](vitest-dev/vitest@eaa119f))
-   **ui:** tasks state group ([7782e7d](vitest-dev/vitest@7782e7d))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1348
Co-authored-by: renovate <[email protected]>
Co-committed-by: renovate <[email protected]>
chaii3 pushed a commit to chaii3/vitest that referenced this issue May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant