Skip to content

Comments

fix: one-line environment options#5105

Merged
sheremet-va merged 2 commits intovitest-dev:mainfrom
hahanein:environment-options-bug
Jul 15, 2024
Merged

fix: one-line environment options#5105
sheremet-va merged 2 commits intovitest-dev:mainfrom
hahanein:environment-options-bug

Conversation

@hahanein
Copy link
Contributor

@hahanein hahanein commented Feb 2, 2024

Description

Closes #5104

Environment options cannot be parsed when declared like so:

/** @vitest-environment-options {"url": "https://vitejs.dev"} */

The regexp captures {"url": "https://vitejs.dev"} */

I would like to add tests but I get hit with the following error message when trying to run them:

examples/graphql test: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/benjamin/projects/vitest/packages/vitest/dist/cli-wrapper.js' imported from /home/benjamin/projects/vitest/packages/vitest/vitest.mjs

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Feb 2, 2024

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 597d80c
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65bd463c67d6b10008bfdb02

@hahanein hahanein changed the title Fix one-line environment options bug fix: one-line environment options Feb 2, 2024
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Feb 4, 2024

I would like to add tests but I get hit with the following error message when trying to run them

Maybe you forgot pnpm dev (or pnpm build)?

vitest/CONTRIBUTING.md

Lines 16 to 22 in cfd0611

1. Run `pnpm install` in `vitest`'s root folder
2. Run `pnpm run dev` to build sources in watch mode
3. Run
- `pnpm run test` to run core tests
- `pnpm run test:all` to run all the suite

@sheremet-va
Copy link
Member

Any changes?

@hahanein hahanein closed this Jul 14, 2024
@hahanein hahanein force-pushed the environment-options-bug branch from 597d80c to f851982 Compare July 14, 2024 13:24
@hahanein hahanein reopened this Jul 14, 2024
@hahanein hahanein force-pushed the environment-options-bug branch from 0902212 to 49c3315 Compare July 14, 2024 14:26
Previously vitest failed to parse environment options when they were
provided as a single line doc block like so:

    /** @vitest-environment-options {"url": "https://vitejs.dev"} */

The regular expression erroneously captured the JSON as well as " */".
@hahanein hahanein force-pushed the environment-options-bug branch from 49c3315 to f88348b Compare July 14, 2024 14:32
@hahanein
Copy link
Contributor Author

I updated the pull request and use endsWith() and slice() to avoid super-linear backtracking.

@sheremet-va sheremet-va merged commit 3826941 into vitest-dev:main Jul 15, 2024
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 this pull request may close these issues.

Fails parsing single line environment options

3 participants