Hi folks - I'm new here (and to Discord), so apolo...
# component-testing
j
Hi folks - I'm new here (and to Discord), so apologies if I get this wrong. I'm trying to do some component testing using Cypress. My app is a React front-end with a Laravel/PHP backend. We use a library called 'Ziggy' for routing, and there's some magic that happens at build time, where any reference to
route()
in the application code is resolved by the build process. Fast-forward to component testing - my application code / component references this
route()
function. I'm trying to stub it out:
Copy code
import { route } from 'ziggy-js';
...
beforeEach(() => {
        const submitUrl = 'support.store';
        const cancelUrl = 'users.index';

        cy.stub(route).as('route');
        cy.mount(
            <SupportForm
                submitUrl={submitUrl}
                cancelUrl={cancelUrl}
            />
        );
}
But whenever the code is called in the test, I get: > - click > (uncaught exception)ReferenceError: route is not defined