Skip to content

When plugins/index.js file is left blank, need more descriptive error on what to export #6611

Closed
@xxinyiwho

Description

@xxinyiwho

Message: The pluginsFile must export a function.

We loaded the pluginsFile from: /Users/xinyi/Documents/X/Xinyi/event-calendar-app/cypress/plugins/index.js

It exported:

Details: {}

Stack trace:

[object Object]
    at Object.get (/Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:344:11)
    at EventEmitter.<anonymous> (/Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/index.js:105:21)
    at EventEmitter.emit (events.js:203:13)
    at ChildProcess.<anonymous> (/Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:25:29)
    at ChildProcess.emit (events.js:203:13)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
From previous event:
    at fn (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:88596:14)
    at ipcBus (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:88614:10)
    at Object.ipc.<computed> [as openProject] (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:88655:69)
    at openProject (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:91044:67)
    at file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:91063:12
From previous event:
    at Object.reopenProject (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:91062:32)
    at Project._this._reopenProject (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:90605:78)
    at Object.ka (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63367:205)
    at qa (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63367:359)
    at ra (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63368:35)
    at wa (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63368:236)
    at Aa (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63369:248)
    at ya (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63369:57)
    at Ba (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63369:412)
    at Kd (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63433:493)
    at hb (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63637:185)
    at Qd (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63435:253)
    at Hc (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63436:470)
    at Pd (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63436:98)
    at ../../node_modules/scheduler/cjs/scheduler.production.min.js.exports.unstable_runWithPriority (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:73703:437)
    at fg (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63472:325)
    at fb (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63637:46)
    at Nd (file:///Users/xinyi/Library/Caches/Cypress/4.1.0/Cypress.app/Contents/Resources/app/packages/desktop-gui/dist/app.js:63434:277)

Activity

jennifer-shehane

jennifer-shehane commented on Mar 2, 2020

@jennifer-shehane
Member

@xxinyiwho Can you provide the code in your plugings/index.js? (Feel free to remove any sensitive info)

The plugins/index.js file will technically export whatever you tell it to export, but there could be a bug with the usage depending on what we see from your file.

xxinyiwho

xxinyiwho commented on Mar 2, 2020

@xxinyiwho
Author

@jennifer-shehane thanks for your quick reply!! I havent change anything in the index file, please see the following:

/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
 * @type {Cypress.PluginConfig}
 */
// module.exports = (on, config) => {
//   // `on` is used to hook into various events Cypress emits
//   // `config` is the resolved Cypress config
// }

// CLEAN DATABASE NOT WORKING
// module.exports = on => {
//   on('task', {
//     'db:teardown': () => {
//       const teardown = require('../../db/teardown.js')
//       return teardown()
//     },
//     'db:seed': () => {
//       const seed = require('../../db/seed.js')
//       return seed()
//     },
//   })
// }
jennifer-shehane

jennifer-shehane commented on Mar 3, 2020

@jennifer-shehane
Member

Hey @xxinyiwho, you have changed the content from the originally seeded plugins/index.js file. The plugins/index.js file requires that you export the function below code at a minimum to work within Cypress, which you have commented out.

module.exports = (on, config) => {}

I do however feel that this error could maybe be improved, so will keep this issue open to improve this error message.

Current error if plugins/index.js file is blank

Screen Shot 2020-03-03 at 3 41 41 PM

Code for error message: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/errors.coffee#L589:L589

The error message should at the least link to https://on.cypress.io/writing-a-plugin

changed the title [-]PLUGIN INDEX FILE EXPORTING OBJECT INSTEAD OF FUNCTION[/-] [+]When `plugins/index.js` file is left blank, need more descriptive error on what to export[/+] on Mar 3, 2020
xxinyiwho

xxinyiwho commented on Mar 4, 2020

@xxinyiwho
Author

Hi Jennifer, I tried to remove the comment too still didnt work. in the end I uninstalled it and reinstalled again but with react test config. Thank you for your answers

3 remaining items

cypress-bot

cypress-bot commented on May 26, 2020

@cypress-bot
Contributor

The code for this is done in cypress-io/cypress#7381, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

cypress-bot

cypress-bot commented on May 26, 2020

@cypress-bot
Contributor

Released in 4.7.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.7.0, please open a new issue.

locked as resolved and limited conversation to collaborators on May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @jennifer-shehane@xxinyiwho

      Issue actions

        When `plugins/index.js` file is left blank, need more descriptive error on what to export · Issue #6611 · cypress-io/cypress