0

I am getting error when running the cypress test on buildkite as below:

Status: Downloaded newer image for cypress/included:6.1.0

[2022-01-31T10:32:13Z] Your pluginsFile is set to /e2e/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.

Error: Cannot find module 'xlsx' Require stack:

  • /e2e/cypress/plugins/read-xlsx.js
  • /e2e/cypress/plugins/index.js

the same test runs fine on local on both browser and headless

"xlsx" is present in the package.json as both dependencies and dev dependencies.

code inside read-xlsx

const XLSX = require("xlsx");
const fs = require("fs");

const read = ({file, sheet}) => {
  const buf = fs.readFileSync(file);
  const workbook = XLSX.read(buf, { type: 'buffer' });
  const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
  return rows
}
 
module.exports = {
  read
}

Someone please help

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
  • How have you set up the code inside the `read-xlsx.js` file? – jjhelguero Jan 31 '22 at 23:23
  • ``` const XLSX = require("xlsx"); const fs = require("fs"); const read = ({file, sheet}) => { const buf = fs.readFileSync(file); const workbook = XLSX.read(buf, { type: 'buffer' }); const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]); return rows } module.exports = { read } ``` – Suprabha Chaudhary Jan 31 '22 at 23:31
  • i have pasted the code in the original question also. Thanks jjhelguero – Suprabha Chaudhary Jan 31 '22 at 23:36

1 Answers1

0

I had the same problem. But in my case, was an issue with case sensitive. I put 'XLSX' inside the require in the read-xlsx.js file.

My read-xlsx.js file became like this and worked:

const fs = require('fs')
const XLSX = require('xlsx')
Pedro
  • 1
  • 1