helpful-receptionist-4197
05/23/2023, 6:47 PM// src/foo.ts
export const FOO = import.meta.url;
In my real code it uses import.meta.url to contrive the path to a file in the 'public' directory. Hard-coding "/path/to/whatever.json" works in prod but doesn't work in cypress component tests which is why i have to use import.meta.url.
foo.ts works fine when imported by the web app and from component tests; problem is only when i also try to access it from cypress e2e test code.
// cypress/e2e/example.cy.ts
import { FOO } from "../../src/foo"; // (also, how do i get the '@' prefix to work?)
describe('My First Test', () => {
it('visits the app root url', () => {
cy.visit('/')
cy.contains('h1', 'You did it!')
})
})