Skip to content

Commit

Permalink
fix import aliases in cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemh committed Jun 22, 2024
1 parent 08c800f commit 2cd2235
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/join.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jwt_decode from 'jwt-decode'; // eslint-disable-line camelcase
import jwtDecode from 'jwt-decode';
import { validationErrorMessages } from '@/common/constants/messages';
import existingUser from '@/test-utils/mocks/existingUser';
import mockUser from '@/test-utils/mockGenerators/mockUser';
Expand Down Expand Up @@ -311,7 +311,7 @@ describe('join', () => {
cy.get('h1').should('have.text', 'Update Profile');

cy.getCookies().then(([tokenCookie]) => {
const jwt = jwt_decode(tokenCookie.value);
const jwt = jwtDecode(tokenCookie.value);

expect(jwt.firstName).to.exist;
expect(jwt.lastName).to.exist;
Expand Down
29 changes: 15 additions & 14 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable global-require */

// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
Expand All @@ -7,23 +9,15 @@
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

const path = require('path');
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');
const webpack = require('@cypress/webpack-preprocessor');
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
// eslint-disable-next-line no-unused-vars
/* eslint-disable global-require */
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

if (!!process.env.CI) {
addMatchImageSnapshotPlugin(on, config);
require('@cypress/code-coverage/task')(on, config);
on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'));
}

module.exports = (
on, // `on` is used to hook into various events Cypress emits
config, // `config` is the resolved Cypress config
) => {
// this fixes aliasing in cypres e2e tests
// https://github.com/cypress-io/cypress/issues/3262#issuecomment-462646891
on(
Expand All @@ -32,12 +26,19 @@ module.exports = (on, config) => {
webpackOptions: {
resolve: {
alias: {
'@/': path.resolve('../../'),
'@': path.resolve(__dirname, '../../'),
},
},
},
watchOptions: {},
}),
);

if (!!process.env.CI) {
addMatchImageSnapshotPlugin(on, config);
require('@cypress/code-coverage/task')(on, config);
on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'));
}

return config;
};

0 comments on commit 2cd2235

Please sign in to comment.