Open rklos opened 2 years ago
has anyone cracked this?
Can anyone investigate this topic?
+1
Bump!
I'm having the same issue where @nuxtjs/i18n isn't loaded which messes up components that use translations
Bump!
I also have the same problem with a nuxt 2 project that is using
'@nuxtjs/composition-api/module',
Me too!
same problem using @nuxtjs/composition-api/module
in nuxt 2 project
+1 here. Trying to install cypress on an existing project with multiple plugins.
+1 there.
Realy need this function
+1
I wanna to share example of my code
I use vuetify, axios and event bus
import './commands';
import axios from 'axios';
import { mount } from 'cypress/vue2';
import Vuetify from 'vuetify';
import Vue from 'vue';
Vue.use(Vuetify);
import '../../../client/assets/app.css';
import 'vuetify/dist/vuetify.min.css';
import { VApp } from 'vuetify/lib/components/VApp';
const vuetifyOptions = {};
import applyConverters from 'axios-case-converter';
Cypress.Commands.add('mount', (component, args) => {
const axiosPlugin = {
install(app) {
app.prototype.$axios = axios;
},
};
const busPlugin = {
install(app) {
app.prototype.$bus = new Vue();
},
};
args = args || {};
applyConverters(axios, {
ignoreHeaders: true,
});
args.extensions = args.extensions || {};
args.extensions.plugins = args.extensions.plugins || [];
args.extensions.plugins.push(axiosPlugin);
args.extensions.plugins.push(busPlugin);
args.vuetify = new Vuetify(vuetifyOptions);
// return mount(component, args);
return mount({ render: h => h(VApp, [h(component, args)]) }, args);
});
What would you like?
For now, component testing in cypress doesn't load up plugins and modules listed in
nuxt.config.js
file when used with NuxtJS framework.It will be nice to have an option to include NuxtJS plugin or module inside tests.
There is a way to load "pure Vue" plugins in
@cypress/vue
package, but NuxtJS modules and plugins have different interface and approach.So we need dedicated option for loading extensions made for NuxtJS.
Why is this needed?
Most of components in my project depend on many different modules imported into NuxtJS in
nuxt.config.js
.For example, my component uses dayjs from this module: https://www.npmjs.com/package/@nuxtjs/dayjs. For now component testing throws errors because of undefined
this.$dayjs
.Another example: almost every of my component contains at least one child component from Vuetify module (https://www.npmjs.com/package/@nuxtjs/vuetify). Now in each test, part of HTML template is not rendered due to missing components from the Vuetify module. I use nearly all of them, so mocking almost the entire library seems hard and impossible to maintain.
Some of NuxtJS modules/plugins has their equivalents in "pure Vue" (and can be used as a normal plugin inside
@cypress/vue
, but this sometimes requires installing a separate package just for testing purposes). But there are some extensions that are made especially for Nuxt, and we will have to do some odd hacky workarounds (that are sometimes almost impossible without forking and exporting some stuff outside the module).Anyway, if cypress have an option to select Nuxt as a framework inside Component Testing settings, I will expect that as basic stuff as plugins and modules in Nuxt will work without any advanced hacks and workarounds.
Other
Steps to reproduction: