Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress Task: The plugins file is missing or invalid. #8994

Closed
omelnik opened this issue Oct 28, 2020 · 7 comments
Closed

Cypress Task: The plugins file is missing or invalid. #8994

omelnik opened this issue Oct 28, 2020 · 7 comments

Comments

@omelnik
Copy link

omelnik commented Oct 28, 2020

When I added my custom task I started getting some errors and I'm not sure how to solve it. I was following the example from RWA: https://github.com/cypress-io/cypress-realworld-app/blob/develop/cypress/plugins/index.ts

cypress/plugins/index.js

import axios from "axios";
import { percyHealthCheck } from "@percy/cypress/task";
import { bookingCancel } from "../../server/api/booking-controller";

export default (on, config) => {
  on("task", {
    percyHealthCheck,
    async "my:task"() {
       /// 
      });
      return response;
    },
  });
  return config;
};

My errors:

Error: The plugins file is missing or invalid.

Your `pluginsFile` is set to `/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.
    at Object.get (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:968:15)
    at EventEmitter.<anonymous> (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/index.js:144:21)
    at EventEmitter.emit (events.js:310:20)
    at ChildProcess.<anonymous> (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22)
    at ChildProcess.emit (events.js:310:20)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)

/cypress/plugins/index.js:1
import { percyHealthCheck } from "@percy/cypress/task";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1051:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
    at Module.load (internal/modules/cjs/loader.js:981:32)
    at Module._load (internal/modules/cjs/loader.js:881:14)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at runPlugins (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:213:15)
    at Object.<anonymous> (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js:8:25)
    at Module._compile (internal/modules/cjs/loader.js:1145:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
    at Module.load (internal/modules/cjs/loader.js:981:32)
    at Module._load (internal/modules/cjs/loader.js:881:14)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)

NOTE: I verified that pluginsFile has the correct path and I even tried explicitly provide the path to the file and it didn't resolve the problem.

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Oct 28, 2020

The export default pattern works on a TypeScript file being used as the pluginsFile.

Works in /plugins/index.ts, does not work in /plugins/index.js

export default () => {};

@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Oct 28, 2020
@jayarjo
Copy link

jayarjo commented Oct 28, 2020

When I change file extension to .ts Cypress stops finding pluginsFile altogether:

Screen Shot 2020-10-28 at 1 48 58 PM

pluginsFile is changed accordingly in cypress.json to cypress/plugins/index.ts and yet.

@jennifer-shehane
Copy link
Member

You need to restart cypress after changing the name of the file, did you restart cypress?

@omelnik
Copy link
Author

omelnik commented Oct 30, 2020

I found the way how to solve my problem. I had to separate percyHealthCheck with my personal tasks:

module.exports = (on, config) => {
  on("task", percyHealthCheck);

  on("task", {
    async "my:task"() {
             ///
    },
  });
  return config;
};

@omelnik omelnik closed this as completed Oct 30, 2020
@jennifer-shehane jennifer-shehane removed the stage: awaiting response Potential fix was proposed; awaiting response label Nov 9, 2020
@AbubakarOM
Copy link

@jennifer-shehane my scripts as been working well before, but upon loading it this morning i saw this error message [26812:1201/075654.687:ERROR:gpu_init.cc(453)] Passthrough is not supported, GL is disabled, ANGLE is , kindly assist in fixing this error message.
I have used the above code you share
export default () =>{}; but not working for me.
I have renamed my folder and restart even my system but still keep getting the same error message.

@ralyodio
Copy link

How do I fix? I'm using js

@devrsi0n
Copy link

I searched a lot of pages, it turns out I missed the typescript in devDependencies.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants