quasarframework / quasar-testing

Testing Harness App Extensions for the Quasar Framework 2.0+
https://testing.quasar.dev
MIT License
179 stars 66 forks source link

Unable to test components when using custom node_modules folder #223

Closed lavoscore closed 2 years ago

lavoscore commented 2 years ago

Upgrading to "@quasar/quasar-app-extension-testing-e2e-cypress@^4.1.0" gives me the error Cannot find module '@quasar/app/lib/app-extension/extensions-runner' on yarn test:component. The underlying cause is the line below:

// /node_modules/@quasar/quasar-app-extension-testing-e2e-cypress/cct-dev-server/index.js
...
async function exportQuasarConfig(bundler) {
    let quasarAppPackage = `@quasar/app-${bundler}`;
    if (bundler === 'webpack') {
        try {
            await exec('npm ls @quasar/app-webpack'); // This fails with Error: Command failed: npm ls @quasar/app-webpack...
        }
        catch (e) {
            // ...defaulting quasarAppPackage to a non-existing path
            quasarAppPackage = '@quasar/app';
        }
    }
...

After investigating, it seems the command fails for custom node_modules folders. My project runs in a Docker container, so I added a .yarnrc file containing --modules-folder /node_modules so as not to pollute my project with the packages (as per this tip). If I prepend cd /node_modules && to the exec above, everything runs fine. Since this AE has worked in my project in previous versions, is this a breaking change? How can I reconcile this version with a custom node_modules folder?

Things I've tried:

IlCallo commented 2 years ago

Is this a breaking change? How can I reconcile this version with a custom node_modules folder?

Up until now there was just one quasar/app package, but we now need to support many: 2 of them, plus the old one as fallback. This forces to import them dynamically and check which one is there first I rely on npm, which I thought would always be present into the system, to tell me if the package we need exists, otherwise load the fallback one

I'm not really sure how I can help you in this edge case as I don't know docker that much, and never used a custom node_modules folder. A possible change on our side would be to load the package.json and check devDependencies to understand which quasar app package is used Would you like to try a PR for this? Should be pretty easy

lavoscore commented 2 years ago

Got it working with the package.json approach. Gonna try and submit a PR. Thanks!

Edit: PR #224 submitted