Skip to content

Commit

Permalink
migrate from vue-cli to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
prigaux committed Jan 29, 2024
1 parent 5e50af0 commit 76ffef9
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 20 deletions.
7 changes: 3 additions & 4 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"build:atomic": "vite build --outDir dist.new && rm -rf dist && mv dist.new dist",
"test:unit": "vue-cli-service test:unit",
"test:unit": "vitest --environment jsdom",
"typecheck": "vue-tsc --noEmit"
},
"dependencies": {
Expand All @@ -31,14 +31,13 @@
"vue-tsc": "^1.8.1"
},
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.4",
"@vue/test-utils": "^1.0.0-beta.20",
"autoprefixer": "^9.5.0",
"axios-mock-adapter": "^1.19.0",
"chai": "^4.2.0",
"jsdom": "^22.1.0",
"postcss-import": "^12.0.1",
"promise-polyfill": "^6.1.0",
"vitest": "^0.32.2",
"vue-template-compiler": "^2.7.10"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion app/tests/unit/attrs/genericAttr.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert, describe, it } from 'vitest';
import * as _ from 'lodash'
import { mount, createLocalVue, Wrapper } from '@vue/test-utils'
import { flushPromises } from '../test_utils';
import { assert } from 'chai';
import AsyncComputed from 'vue-async-computed';
import genericAttr from '@/attrs/genericAttr.vue';

Expand Down
2 changes: 1 addition & 1 deletion app/tests/unit/controllers/StepV-and-attrsForm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert, describe, it } from 'vitest';
import * as _ from 'lodash'
import { mount, createLocalVue } from '@vue/test-utils'
//import { mocha_axios_mock, flushPromises } from '../test_utils';
import VueRouter from 'vue-router'
import { assert } from 'chai';
import StepV from '@/controllers/StepV.vue';
import { flushPromises } from '../test_utils';

Expand Down
2 changes: 1 addition & 1 deletion app/tests/unit/controllers/StepV.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert, describe, it } from 'vitest'
import * as _ from 'lodash'
import { mount, createLocalVue } from '@vue/test-utils'
import { mocha_axios_mock, flushPromises } from '../test_utils';
import VueRouter from 'vue-router'
import { assert } from 'chai';
import StepV from '@/controllers/StepV.vue';


Expand Down
2 changes: 1 addition & 1 deletion app/tests/unit/services/address.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from 'chai';
import { assert, describe, it } from 'vitest';
import * as Address from '@/../../shared/address';
import * as Helpers from '@/services/helpers';

Expand Down
3 changes: 1 addition & 2 deletions app/tests/unit/services/axios-mock-adapter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { assert } from 'chai';

import { assert, describe, it } from 'vitest';
import axios from 'axios';
import { mocha_axios_mock, should_throw } from '../test_utils';

Expand Down
2 changes: 1 addition & 1 deletion app/tests/unit/services/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from 'chai';
import { assert, describe, it } from 'vitest';
import * as Helpers from '@/services/helpers';
import * as JsDiff from 'diff';

Expand Down
2 changes: 1 addition & 1 deletion app/tests/unit/services/mppp_and_defaults.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from 'chai';
import { assert, describe, it } from 'vitest'
import { forIn } from 'lodash';
import { compute_mppp_and_handle_default_values as compute } from '@/../../shared/mppp_and_defaults';
import { V, StepAttrsOption } from '@/services/ws';
Expand Down
6 changes: 3 additions & 3 deletions app/tests/unit/test_utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import MockAdapter from "axios-mock-adapter"
import { assert } from 'chai';
import { setTimeoutPromise } from '../../../shared/helpers';
import { assert, afterAll, afterEach, beforeAll } from 'vitest';

export const should_throw = (p, validateException) => (
p.then(_ => assert.fail("should have failed"), (e) => validateException(e))
Expand All @@ -13,8 +13,8 @@ export const flushPromises = async () => {

export const mocha_axios_mock = () => {
let o = { adapter: undefined as MockAdapter }
before(() => o.adapter = new MockAdapter(axios))
beforeAll(() => { o.adapter = new MockAdapter(axios) })
afterEach(() => o.adapter.reset())
after(() => o.adapter.restore())
afterAll(() => o.adapter.restore())
return o
}
5 changes: 0 additions & 5 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"mocha",
"chai"
],
"paths": {
"@/*": [
"src/*"
Expand Down

0 comments on commit 76ffef9

Please sign in to comment.