question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intro Examples not working, Vue-Cli 3, fresh install

See original GitHub issue

BUG

  • version 1.11.0 package.json:
{
  "name": "cypress-test-3000",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:e2e": "vue-cli-service test:e2e"
  },
  "dependencies": {
    "vue": "^2.5.17"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.1.0",
    "@vue/cli-plugin-e2e-cypress": "^3.1.0",
    "@vue/cli-service": "^3.1.0",
    "cypress-vue-unit-test": "^1.11.0",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "vue-template-compiler": "^2.5.17"
  }

Terminal says

GET /__/ 200 18.770 ms - -
GET /__cypress/runner/cypress_runner.css 200 36.240 ms - -
GET /__cypress/runner/cypress_runner.js 200 281.366 ms - -
GET /__cypress/runner/fonts/fontawesome-webfont.woff2?v=4.6.3 200 1.661 ms - 71896
GET /__cypress/iframes/integration/test.js 200 6.710 ms - 709
(node:2412) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
HEAD / 500 4527.223 ms - -
HEAD / 500 4537.110 ms - -
HEAD / 500 4543.925 ms - -
  • platform Win 10, VS Code (Terminal is Git Bash),
  • expected behavior to show at least the cypress logs
  • actual behavior On cypress open or npm run test:e2e, clicking the spec -> chrome opens, not showing anything but “waiting on localhost”. Then after quite a while stops with “not tests found”

Additional Information: fresh install with vue-cli 3, intro examples from docs also don’t work, test.js

import mountVue from 'cypress-vue-unit-test';
import HelloWorld from '../../../src/components/HelloWorld.vue';

describe('HelloWorld', () => {
    beforeEach(mountVue(HelloWorld));

    describe('clicking the save button', () => {
        let spy;

        beforeEach(() => {
            spy = cy.spy();
            Cypress.vue.$on('save', spy);

            cy.get("[data-test='messageText']")
                .type('New message');

            cy.get("[data-test='saveButton']")
                .click();
        });

        it('clears the text field', () => {
            cy.get("[data-test='messageText']")
                .should('have.value', '');
        });

        it('emits the "save" event', () => {
            expect(spy).to.have.been.calledWith('New message');
        });
    });
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
c0h1b4commented, Nov 26, 2018

I think I solved it:

from https://learntdd.in/vue/

yarn add --dev cypress-vue-unit-test \
                 @cypress/webpack-preprocessor \
                 vue-loader

on the file tests/e2e/plugins/index.js

const webpack = require('@cypress/webpack-preprocessor');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

const webpackOptions = {
  resolve: {
    extensions: ['.js', '.vue'],
  },
  plugins: [
    new VueLoaderPlugin(),
  ],
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
      },
    ],
  },
};

const options = {
  // send in the options from your webpack.config.js, so it works the same
  // as your app's code
  webpackOptions,
  watchOptions: {},
};

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

Then run “yarn test:e2e” again and component tests should work…

1reaction
paxcodescommented, Feb 26, 2019

@sebastianjung you have to add a css loader in the webpack config to properly compile them.

...
 rules: [
   ...
     {
        test: /\.css$/,
        use: ["vue-style-loader", "css-loader"]
      }
...

Check out the vue-loader documentation for more info.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Vue CLI
This document covers some common Vue CLI issues and how to resolve them. You should always follow these steps before opening a new...
Read more >
Install Vue CLI and create a project in Vue 3 | TSH.io
Install Vue CLI and make it much easier to start and manage new Vue projects. Learn how to create new Vue CLI project....
Read more >
A Beginner's Guide to Vue CLI - SitePoint
I'll demonstrate how to install the latest version of Vue CLI and how to create, serve and build an example project. Want to...
Read more >
Vue cli 3 hot reload suddenly not working in browsers
I have a Vue project generated by the Vue cli 3 and my hot reloading suddenly stopped working in my browsers. Changes made...
Read more >
Creating Your First Vue 3 Project - A Vue Tutorial - LearnVue
First, we have to make sure that we have the most up-to-date version of the Vue CLI and we can do that by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found