cypress-fail-on-console-error
cypress-fail-on-console-error copied to clipboard
Webpack compilation error with sinon api
I am using [email protected] [email protected] [email protected]
I am having webpack error, when using cypress-fail-on-console-error in my framework. I have followed all the possibilities including updating the node_modules with the latest version still problem is not resolved
looks like cypress-fail-on-console-error is not handling optional chaining operator and webpack unable to parse it. I used babel-loader but its no use.
here is my code in test.cy.js `/**
- @type {Config} */ const config = { consoleMessages: [ ], consoleTypes: ['error'], };
failOnConsoleError(config); const { getConfig } = failOnConsoleError(config); Cypress.Commands.add('getConsoleError',(url) =>{ console.log("in cypress custom commands"); cy.visit(url); getConsoleMessages: () => cy.wrap(getConfig().consoleMessages); });
describe('verify console errors',()=>{ it('verify console errors in google search page',()=>{ cy.getConsoleError("https://www.google.com"); }); });
` I even included webpack.config.js in my framework,
`const path = require('path');
module.exports = { mode: 'none', resolve: { extensions: ['.js', '.jsx'], },
module: { rules: [ { test: /.js?$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], }, }, }, ], }, }; ` In plugins/index.js,
` const webpackPreprocessor = require('@cypress/webpack-preprocessor'); const webpackOptions = require('../../webpack.config.js'); module.exports = (on, config) => { const options = { webpackOptions, watchOptions: {}, };
on('file:preprocessor', webpackPreprocessor(options)) }; `