| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -241,6 +241,7 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => { | |||
| 241 | 241 | 'vitest > @vitest/snapshot > magic-string', | |
| 242 | 242 | 'vitest > chai', | |
| 243 | 243 | 'vitest > chai > loupe', | |
| 244 | + 'vitest > strip-literal', | ||
| 244 | 245 | 'vitest > @vitest/utils > loupe', | |
| 245 | 246 | '@vitest/browser > @testing-library/user-event', | |
| 246 | 247 | '@vitest/browser > @testing-library/dom', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,6 +43,7 @@ | |||
| 43 | 43 | }, | |
| 44 | 44 | "dependencies": { | |
| 45 | 45 | "@vitest/utils": "workspace:*", | |
| 46 | - "pathe": "catalog:" | ||
| 46 | + "pathe": "catalog:", | ||
| 47 | + "strip-literal": "catalog:" | ||
| 47 | 48 | } | |
| 48 | 49 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | import type { VitestRunner } from './types' | |
| 2 | 2 | import type { FixtureOptions, TestContext } from './types/tasks' | |
| 3 | 3 | import { createDefer, isObject } from '@vitest/utils' | |
| 4 | + import { stripLiteral } from 'strip-literal' | ||
| 4 | 5 | import { getFileContext } from './context' | |
| 5 | 6 | import { getTestFixture } from './map' | |
| 6 | 7 | ||
@@ -338,9 +339,9 @@ function resolveDeps( | |||
| 338 | 339 | } | |
| 339 | 340 | ||
| 340 | 341 | function getUsedProps(fn: Function) { | |
| 341 | - let fnString = fn.toString() | ||
| 342 | + let fnString = stripLiteral(fn.toString()) | ||
| 342 | 343 | // match lowered async function and strip it off | |
| 343 | - // example code on esbuild-try https://esbuild.github.io/try/#YgAwLjI0LjAALS1zdXBwb3J0ZWQ6YXN5bmMtYXdhaXQ9ZmFsc2UAZQBlbnRyeS50cwBjb25zdCBvID0gewogIGYxOiBhc3luYyAoKSA9PiB7fSwKICBmMjogYXN5bmMgKGEpID0+IHt9LAogIGYzOiBhc3luYyAoYSwgYikgPT4ge30sCiAgZjQ6IGFzeW5jIGZ1bmN0aW9uKGEpIHt9LAogIGY1OiBhc3luYyBmdW5jdGlvbiBmZihhKSB7fSwKICBhc3luYyBmNihhKSB7fSwKCiAgZzE6IGFzeW5jICgpID0+IHt9LAogIGcyOiBhc3luYyAoeyBhIH0pID0+IHt9LAogIGczOiBhc3luYyAoeyBhIH0sIGIpID0+IHt9LAogIGc0OiBhc3luYyBmdW5jdGlvbiAoeyBhIH0pIHt9LAogIGc1OiBhc3luYyBmdW5jdGlvbiBnZyh7IGEgfSkge30sCiAgYXN5bmMgZzYoeyBhIH0pIHt9Cn0 | ||
| 344 | + // example code on esbuild-try https://esbuild.github.io/try/#YgAwLjI0LjAALS1zdXBwb3J0ZWQ6YXN5bmMtYXdhaXQ9ZmFsc2UAZQBlbnRyeS50cwBjb25zdCBvID0gewogIGYxOiBhc3luYyAoKSA9PiB7fSwKICBmMjogYXN5bmMgKGEpID0+IHt9LAogIGYzOiBhc3luYyAoYSwgYikgPT4ge30sCiAgZjQ6IGFzeW5jIGZ1bmN0aW9uKGEpIHt9LAogIGY1OiBhc3luYyBmdW5jdGlvbiBmZihhKSB7fSwKICBhc3luYyBmNihhKSB7fSwKCiAgZzE6IGFzeW5jICgpID0+IHt9LAogIGcyOiBhc3luYyAoeyBhIH0pID0+IHt9LAogIGczOiBhc3luYyAoeyBhIH0sIGIpID0+IHt9LAogIGc0OiBhc3luYyBmdW5jdGlvbiAoeyBhIH0pIHt9LAogIGc1OiBhc3luYyBmdW5jdGlvbiBnZyh7IGEgfSkge30sCiAgYXN5bmMgZzYoeyBhIH0pIHt9LAoKICBoMTogYXN5bmMgKCkgPT4ge30sCiAgLy8gY29tbWVudCBiZXR3ZWVuCiAgaDI6IGFzeW5jIChhKSA9PiB7fSwKfQ | ||
| 344 | 345 | // __async(this, null, function* | |
| 345 | 346 | // __async(this, arguments, function* | |
| 346 | 347 | // __async(this, [_0, _1], function* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -201,7 +201,7 @@ | |||
| 201 | 201 | "mime": "^4.0.7", | |
| 202 | 202 | "pretty-format": "^29.7.0", | |
| 203 | 203 | "prompts": "^2.4.2", | |
| 204 | - "strip-literal": "^3.0.0", | ||
| 204 | + "strip-literal": "catalog:", | ||
| 205 | 205 | "ws": "catalog:" | |
| 206 | 206 | } | |
| 207 | 207 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,7 @@ catalog: | |||
| 37 | 37 | pathe: ^2.0.3 | |
| 38 | 38 | sirv: ^3.0.1 | |
| 39 | 39 | std-env: ^3.9.0 | |
| 40 | + strip-literal: ^3.0.0 | ||
| 40 | 41 | test-exclude: ^7.0.1 | |
| 41 | 42 | tinyglobby: ^0.2.14 | |
| 42 | 43 | tinyrainbow: ^2.0.0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,53 @@ | |||
| 1 | + /* eslint-disable style/spaced-comment */ | ||
| 2 | + import { test as base, expect } from 'vitest' | ||
| 3 | + | ||
| 4 | + const test = base.extend<{ | ||
| 5 | + one: 1 | ||
| 6 | + two: 2 | ||
| 7 | + }>({ | ||
| 8 | + one: 1, | ||
| 9 | + two: 2, | ||
| 10 | + }) | ||
| 11 | + | ||
| 12 | + test('no comments', ({ one, two }) => { | ||
| 13 | + expect(one).toBe(1) | ||
| 14 | + expect(two).toBe(2) | ||
| 15 | + }) | ||
| 16 | + | ||
| 17 | + test('inline comment', ({ | ||
| 18 | + one, | ||
| 19 | + // comment | ||
| 20 | + two, | ||
| 21 | + }) => { | ||
| 22 | + expect(one).toBe(1) | ||
| 23 | + expect(two).toBe(2) | ||
| 24 | + }) | ||
| 25 | + | ||
| 26 | + test('multiline comment', ({ | ||
| 27 | + one, | ||
| 28 | + /** | ||
| 29 | + * comment | ||
| 30 | + */ | ||
| 31 | + two, | ||
| 32 | + }) => { | ||
| 33 | + expect(one).toBe(1) | ||
| 34 | + expect(two).toBe(2) | ||
| 35 | + }) | ||
| 36 | + | ||
| 37 | + test('inline legal comment', ({ | ||
| 38 | + one, | ||
| 39 | + //! comment | ||
| 40 | + two, | ||
| 41 | + }) => { | ||
| 42 | + expect(one).toBe(1) | ||
| 43 | + expect(two).toBe(2) | ||
| 44 | + }) | ||
| 45 | + | ||
| 46 | + test('multiline legal comment', ({ | ||
| 47 | + one, | ||
| 48 | + /*! comment */ | ||
| 49 | + two, | ||
| 50 | + }) => { | ||
| 51 | + expect(one).toBe(1) | ||
| 52 | + expect(two).toBe(2) | ||
| 53 | + }) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments