Skip to content

Commit f8ff574

Browse files
committed
Fix component tests
1 parent 7bfe209 commit f8ff574

File tree

5 files changed

+27
-184
lines changed

5 files changed

+27
-184
lines changed

cypress/support/component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ import './commands';
1919
// Alternatively you can use CommonJS syntax:
2020
// require('./commands')
2121

22-
import { mount } from 'cypress/vue2';
23-
// Vue2.7 Workaround to have proper types
24-
import { mount as mount3 } from 'cypress/vue';
22+
import { mount } from 'cypress/vue';
2523

26-
// Augment the Cypress namespace to include type definitions for
27-
// your custom command.
28-
// Alternatively, can be defined in cypress/support/component.d.ts
29-
// with a <reference path="./component" /> at the top of your spec.
3024
declare global {
3125
namespace Cypress {
3226
interface Chainable {
33-
mount: typeof mount3;
27+
mount: typeof mount;
3428
}
3529
}
3630
}
3731

32+
// Augment the Cypress namespace to include type definitions for
33+
// your custom command.
34+
// Alternatively, can be defined in cypress/support/component.d.ts
35+
// with a <reference path="./component" /> at the top of your spec.
36+
// import '../../src/assets/main.css';
37+
3838
Cypress.Commands.add('mount', mount);
3939

4040
// Example use:
41-
// cy.mount(MyComponent)
41+
// cy.mount(MyComponent);s

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
"vue-material-design-icons": "^5.1.2",
3737
"vue-router": "^4.1.6",
3838
"vue-select": "^4.0.0-beta.5",
39-
"vue3-drr-grid-layout": "^1.9.6"
39+
"vue3-drr-grid-layout": "^1.9.7"
4040
},
4141
"devDependencies": {
4242
"@cypress/vite-dev-server": "^4.0.1",
43-
"@cypress/vue": "^2.2.3",
43+
"@cypress/vue": "^5.0.2",
4444
"@types/echarts": "^4.9.16",
4545
"@types/jest": "^27.5.0",
4646
"@typescript-eslint/eslint-plugin": "^2.33.0",
@@ -50,7 +50,7 @@
5050
"@vue/eslint-config-prettier": "^6.0.0",
5151
"@vue/eslint-config-typescript": "^5.1.0",
5252
"@vue/runtime-dom": "^3.2.45",
53-
"@vue/test-utils": "^1.3.3",
53+
"@vue/test-utils": "^2.2.4",
5454
"cypress": "^10.3.0",
5555
"eslint": "^6.7.2",
5656
"eslint-plugin-prettier": "^3.4.1",

src/components/general/ProfitPill.cy.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import ProfitPill from './ProfitPill.vue';
2-
import { createLocalVue } from '@vue/test-utils';
3-
4-
const localVue = createLocalVue();
52

63
describe('ProfitPill.vue', () => {
74
it('Shows a Green pill with positive profits', () => {
85
cy.mount(ProfitPill, {
9-
localVue,
106
propsData: {
117
profitRatio: 0.051,
128
profitAbs: 0.1,
@@ -21,7 +17,6 @@ describe('ProfitPill.vue', () => {
2117
});
2218
it('Shows a Red pill with positive profits', () => {
2319
cy.mount(ProfitPill, {
24-
localVue,
2520
propsData: {
2621
profitRatio: -0.1,
2722
profitAbs: -0.1,
@@ -38,7 +33,6 @@ describe('ProfitPill.vue', () => {
3833
});
3934
it('Shows a pill with 0.0 profits.', () => {
4035
cy.mount(ProfitPill, {
41-
localVue,
4236
propsData: {
4337
profitRatio: 0.0,
4438
profitAbs: 0.0,
@@ -54,7 +48,6 @@ describe('ProfitPill.vue', () => {
5448
});
5549
it('Shows a pill without relative profits.', () => {
5650
cy.mount(ProfitPill, {
57-
localVue,
5851
propsData: {
5952
profitRatio: undefined,
6053
profitAbs: 223,

src/components/general/ProfitSymbol.cy.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import ProfitSymbol from '@/components/general/ProfitSymbol.vue';
2-
import { createLocalVue } from '@vue/test-utils';
3-
4-
const localVue = createLocalVue();
52

63
describe('ProfitSymbol.vue', () => {
74
it('calculates isProfitable with negative profit', () => {
8-
cy.mount(ProfitSymbol, { localVue, propsData: { profit: -0.5 } });
5+
cy.mount(ProfitSymbol, { propsData: { profit: -0.5 } });
96

107
cy.get('div').should('have.class', 'triangle-down');
118
cy.get('div').should('not.have.class', 'triangle-up');
129
});
1310
it('calculates isProfitable with positive profit', () => {
14-
cy.mount(ProfitSymbol, { localVue, propsData: { profit: 0.5 } });
11+
cy.mount(ProfitSymbol, { propsData: { profit: 0.5 } });
1512
cy.get('div').should('have.class', 'triangle-up');
1613
cy.get('div').should('not.have.class', 'triangle-down');
1714
});

0 commit comments

Comments
 (0)