File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
packages/vitest/src/utils Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,13 @@ export async function groupFilesByEnv(
5757 file ,
5858 )
5959
60- const envOptions = JSON . parse (
61- code . match ( / @ (?: v i t e s t | j e s t ) - e n v i r o n m e n t - o p t i o n s \s + ?( .+ ) / ) ?. [ 1 ]
62- || 'null' ,
63- )
60+ let envOptionsJson = code . match ( / @ (?: v i t e s t | j e s t ) - e n v i r o n m e n t - o p t i o n s \s + ( .+ ) / ) ?. [ 1 ]
61+ if ( envOptionsJson ?. endsWith ( '*/' ) ) {
62+ // Trim closing Docblock characters the above regex might have captured
63+ envOptionsJson = envOptionsJson . slice ( 0 , - 2 )
64+ }
65+
66+ const envOptions = JSON . parse ( envOptionsJson || 'null' )
6467 const envKey = env === 'happy-dom' ? 'happyDOM' : env
6568 const environment : ContextTestEnvironment = {
6669 name : env as VitestEnvironment ,
Original file line number Diff line number Diff line change 1+ /** @vitest -environment jsdom */
2+
3+ /** @vitest -environment-options { "url": "https://example.com/" } */
4+
5+ import { expect , it } from 'vitest'
6+
7+ it ( 'parse single line environment options' , ( ) => expect ( location . href ) . toBe ( 'https://example.com/' ) )
You can’t perform that action at this time.
0 commit comments