playwright-test
playwright-test copied to clipboard
Support for `import.meta.url`
Is your feature request related to a problem? Please describe.
I'd like to conditionally load things relative to the test module, which can be achieved as
new URL('./asset.txt', import.meta.url)
However that does not seem to work because import.meta.url
is undefined.
Describe the solution you'd like
Have import.meta.url
be a module URL as loaded by test runner.
Describe alternatives you've considered
Use of fs.readFile
which also does not work
Additional context Would like test new unixfs importer code across node / browser against a ready dataset
This might be a relevant plugin https://www.npmjs.com/package/@chialab/esbuild-plugin-meta-url
Can't really support import.meta.url since tests are all bundled. But you can just fetch any file in cwd or pass --assets and change it another folder
Humm maybe I can define import.meta.url using the file path from esbuild metadata.
This works now https://github.com/hugomrdias/playwright-test/commit/e7bde86b161f950d9fc1587ad2feb50683df790f will be on npm as v9