Cypress error when trying test

I am trying to run a test with cypress for a plugin I created, but I get this error when I run npx cypress run:


There is a cypress.json file at the path: /var/www/ojs_installation

Cypress version 10.0.0 no longer supports cypress.json.

Please run cypress open to launch the migration tool to migrate to cypress.config.{js,ts,mjs,cjs}.

There is actually a cypress.json file inside the installation, but I am wondering if I am doing something wrong with the test workflow. I am following this https://docs.pkp.sfu.ca/dev/testing/en/getting-started#configure-your-environment and already configured the cypress.env.json

Hi, the OJS version is not given in the post but as mentioned that there is a cypress.json file , my guess it’s probably within the range of current stable that is 3.3.0-x . For the current latest stable, the recommended version of cypress is 5.6+ as defined in the package.json file but not as high as 10 as mentioned in the post . Since cypress 10+, it has introduced some breaking changes that include the requirement of cypress.config.js instead of cypress.json .

Regards
PKP Team

Hi touhidur,

thank you very much for your reply and sorry for replying so late. I downgraded the cypress version to 9.7 (my OJS version is 3.3.0.13). Now I get this message:

Your pluginsFile was not found at path: /var/www/ojs_locale/lib/pkp/cypress/plugins/index.js

Create this file, or set pluginsFile to false if a plugins file is not necessary for your project.

If you have just renamed the extension of your pluginsFile, restart Cypress.

Hi Please note that for 3.3.0-x, the cypress version is locked to ^5.6 (as defined in the package.json file) which means version >= 5.6 but < 6.0 . Please try with cypress version within that range .

Regards
PKP Team

I have the 5.6.0 now but it still gives me this error

Your `pluginsFile` is set to `/var/www/ojs_locale/lib/pkp/cypress/plugins/index.js`, but either the file is missing, it contains a syntax error, or threw an error when required. The `pluginsFile` must be a `.js`, `.ts`, or `.coffee` file.

Or you might have renamed the extension of your `pluginsFile`. If that's the case, restart the test runner.

Please fix this, or set `pluginsFile` to `false` if a plugins file is not necessary for your project.

I actually don’t have the folder cypress in lib/pkp in my installation

I actually don’t have the folder cypress in lib/pkp in my installation

If I am not mistaken , you have downloaded the OJS from release page rather than cloning from git . In that case, the cypress test related files/folder are not included into the download package as I think no cypress folder also not available in your installation path. One possible way to include those is to get those from github for branch stable-3_3_0 and put accordingly each cypress folder in installation directory and lib/pkp directory .

Thank you very much, you were right. Now cypress is running tests, but I still get an error and all tests are failing. Maybe I forgot something to copy. This is the error, they seems all similar in a way:

Oops...we found an error preparing this test file:

  cypress/support/index.js

The error was:

Error: Webpack Compilation Error
./cypress/support/index.js
Module not found: Error: Can't resolve '@foreachbe/cypress-tinymce' in '/var/www/ojs_locale/cypress/support'
resolve '@foreachbe/cypress-tinymce' in '/var/www/ojs_locale/cypress/support'
  Parsed request is a module
  using description file: /var/www/ojs_locale/package.json (relative path: ./cypress/support)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /var/www/ojs_locale/cypress/support/node_modules doesn't exist or is not a directory
      /var/www/ojs_locale/cypress/node_modules doesn't exist or is not a directory
      /var/www/node_modules doesn't exist or is not a directory
      /var/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /var/www/ojs_locale/node_modules
        using description file: /var/www/ojs_locale/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /var/www/ojs_locale/package.json (relative path: ./node_modules/@foreachbe/cypress-tinymce)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.json doesn't exist
            .jsx
              Field 'browser' doesn't contain a valid alias configuration
              /var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.jsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.mjs doesn't exist
            .coffee
              Field 'browser' doesn't contain a valid alias configuration
              /var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.coffee doesn't exist
            as directory
              /var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce doesn't exist
[/var/www/ojs_locale/cypress/support/node_modules]
[/var/www/ojs_locale/cypress/node_modules]
[/var/www/node_modules]
[/var/node_modules]
[/node_modules]
[/var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce]
[/var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.js]
[/var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.json]
[/var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.jsx]
[/var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.mjs]
[/var/www/ojs_locale/node_modules/@foreachbe/cypress-tinymce.coffee]
 @ ./cypress/support/index.js 5:0-37

Sorry for all this disturb.

this points that there is no node_modules folder in your installation path .

But actually there is

So, I installed all the cypress dependencies listed in the package.json of the ojs-stable branch, and now it seems to work (but the cypress folder needed to be 777, for it couldn’t mkdir screenshot folder). Thanks!

Just another little thing: I am using the function cy.login with the correct username, password and context, but it doesn’t really logs in: it gives me a 302 Found, but it stays on the login page, without “entering” in the backend section.
Maybe I will just use the standard cypress workaround for logging in, but it doesn’t seems to me that I am doing something wrong and the command for the login seems alright.