Skip to content

console print error when I use cypress work with webpack. #1122

@wangzhenxi

Description

@wangzhenxi

Version

3.0.0-beta.6

Reproduction link

https://codepen.io/imjoshwong/pen/dmEzmB

Steps to reproduce

when I use vue-cli to create a project, I found the created folder haven't "webpack.config.js" file.I use my webpack config to this project and the project can run successfully. Then, I want to test my project, the console printed some error, I want to know why, so I found the document https://github.com/cypress-io/cypress-webpack-preprocessor, and install a plugin "@cypress/webpack-preprocessor", and add some config in plugins config, but the error is still exist.

// tests/plugins/index.js
const webpack = require('@cypress/webpack-preprocessor')

module.exports = (on, config) => {
  on('file:preprocessor', webpack({
    webpackOptions: require('../../webpack.config.js')
  }))
  return Object.assign({}, config, {
    fixturesFolder: 'tests/fixtures',
    integrationFolder: 'tests/specs',
    screenshotsFolder: 'tests/screenshots',
    videosFolder: 'tests/videos',
    supportFile: 'tests/support/index.js'
  })
}

What is expected?

I want to the progress run successfully as the first time.

What is actually happening?

The error is that the process cannot make out the webpack alias, and recommand me to install the alias, that is error absolutely.

Activity

dhensche

dhensche commented on Apr 13, 2018

@dhensche
Contributor

I could be wrong, but I believe the intent with v3.x is to not have a webpack.config.js file per se, and instead use one of documented methods to make webpack modifications.

LinusBorg

LinusBorg commented on Apr 14, 2018

@LinusBorg
Member

@dhesche is correct. If you use vue-cli 3, you don't define any webpack.config.js your own.

laurentpayot

laurentpayot commented on Apr 14, 2018

@laurentpayot

@Joshwoooooooooooooooooooooooooooooooong you have to define your own config as your example is referencing to a non-existing (in vue-cli 3) webpack.config.js file.
This plugin config is used internally by Cypress, to set preprocessors, aliases for imports, loaders etc. To import project file for unit testing with Cypress it should be the same as the Vue config modified with chainWebpack or configureWebpack via vue.config.js.

You can see a full example of the Cypress plugin file here: quasarframework/quasar-cli#83 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dhensche@LinusBorg@laurentpayot@wangzhenxi

        Issue actions

          console print error when I use cypress work with webpack. · Issue #1122 · vuejs/vue-cli