Migrate unit/integration tests to Vitest with Vite
As part of transition to Vue 3.0 and Vite (#230), this commit facilitates the shift towards building rest of the application using Vite. By doing so, it eliminates reliance on outdated Electron building system that offered limited control, blocking desktop builds (#233). Changes include: - Introduce Vite with Vue 2.0 plugin for test execution. - Remove `mocha`, `chai` and other related dependencies. - Adjust test to Vitest syntax. - Revise and update `tests.md` to document the changes. - Add `@modyfi/vite-plugin-yaml` plugin to be able to use yaml file depended logic on test files, replacing previous webpack behavior. - Fix failing tests that are revealed by Vitest due to unhandled errors and lack of assertments. - Remove the test that depends on Vue CLI populating `process.env`. - Use `jsdom` for unit test environment, adding it to dependency to `package.json` as project now depends on it and it was not specified even though `package-lock.json` included it.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { IInstructionsBuilderData, InstructionsBuilder, InstructionStepBuilderType } from '@/presentation/components/Code/CodeButtons/Instructions/Data/InstructionsBuilder';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { MacOsInstructionsBuilder } from '@/presentation/components/Code/CodeButtons/Instructions/Data/MacOsInstructionsBuilder';
|
||||
import { runOsSpecificInstructionBuilderTests } from './OsSpecificInstructionBuilderTestRunner';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect } from 'chai';
|
||||
import { it, expect } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { InstructionsBuilder } from '@/presentation/components/Code/CodeButtons/Instructions/Data/InstructionsBuilder';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { getInstructions, hasInstructions } from '@/presentation/components/Code/CodeButtons/Instructions/InstructionListDataFactory';
|
||||
import { getEnumValues } from '@/application/Common/Enum';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { SelectionType, SelectionTypeHandler } from '@/presentation/components/Scripts/Menu/Selector/SelectionTypeHandler';
|
||||
import { scrambledEqual } from '@/application/Common/Array';
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { NonCollapsing, hasDirective } from '@/presentation/components/Scripts/View/Cards/NonCollapsingDirective';
|
||||
|
||||
const expectedAttributeName = 'data-interaction-does-not-collapse';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
getScriptNodeId, getScriptId, getCategoryNodeId, getCategoryId, parseSingleCategory,
|
||||
parseAllCategories,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ILiquorTreeExistingNode } from 'liquor-tree';
|
||||
import { NodeType, INodeContent } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INodeContent';
|
||||
import { NodePredicateFilter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodePredicateFilter';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ILiquorTreeNode } from 'liquor-tree';
|
||||
import { NodeType } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INodeContent';
|
||||
import { getNewState } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeStateUpdater';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
ILiquorTreeExistingNode, ILiquorTreeNewNode, ILiquorTreeNodeData, ICustomLiquorTreeData,
|
||||
} from 'liquor-tree';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { createRenderer } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Documentation/MarkdownRenderer';
|
||||
|
||||
describe('MarkdownRenderer', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CategoryReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter';
|
||||
import { getCategoryNodeId } from '@/presentation/components/Scripts/View/ScriptsTree/ScriptNodeParser';
|
||||
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { INodeContent, NodeType } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INodeContent';
|
||||
import { getReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/ReverterFactory';
|
||||
import { ScriptReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ScriptReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter';
|
||||
import { getScriptNodeId } from '@/presentation/components/Scripts/View/ScriptsTree/ScriptNodeParser';
|
||||
import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
Wrapper, shallowMount,
|
||||
mount,
|
||||
} from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import { nextTick, defineComponent } from 'vue';
|
||||
import ToggleSwitch from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/ToggleSwitch.vue';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { useApplication } from '@/presentation/components/Shared/Hooks/UseApplication';
|
||||
import { ApplicationStub } from '@tests/unit/shared/Stubs/ApplicationStub';
|
||||
import { ProjectInformationStub } from '@tests/unit/shared/Stubs/ProjectInformationStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { useCollectionState } from '@/presentation/components/Shared/Hooks/UseCollectionState';
|
||||
import { CategoryCollectionStateStub } from '@tests/unit/shared/Stubs/CategoryCollectionStateStub';
|
||||
import { ApplicationContextStub } from '@tests/unit/shared/Stubs/ApplicationContextStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { useEnvironment } from '@/presentation/components/Shared/Hooks/UseEnvironment';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
import { EnvironmentStub } from '@tests/unit/shared/Stubs/EnvironmentStub';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ref, nextTick } from 'vue';
|
||||
import { expect } from 'chai';
|
||||
import { useAllTrueWatcher } from '@/presentation/components/Shared/Modal/Hooks/UseAllTrueWatcher';
|
||||
|
||||
describe('useAllTrueWatcher', () => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ref, nextTick } from 'vue';
|
||||
import { expect } from 'chai';
|
||||
import { useCurrentFocusToggle } from '@/presentation/components/Shared/Modal/Hooks/UseCurrentFocusToggle';
|
||||
|
||||
describe('useCurrentFocusToggle', () => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import { nextTick, defineComponent } from 'vue';
|
||||
import { useEscapeKeyListener } from '@/presentation/components/Shared/Modal/Hooks/UseEscapeKeyListener';
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'mocha';
|
||||
import {
|
||||
describe, it, expect, afterEach,
|
||||
} from 'vitest';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import { ref, nextTick, defineComponent } from 'vue';
|
||||
import { useLockBodyBackgroundScroll } from '@/presentation/components/Shared/Modal/Hooks/UseLockBodyBackgroundScroll';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import ModalContainer from '@/presentation/components/Shared/Modal/ModalContainer.vue';
|
||||
|
||||
const DOM_MODAL_CONTAINER_SELECTOR = '.modal-container';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import ModalContent from '@/presentation/components/Shared/Modal/ModalContent.vue';
|
||||
|
||||
const DOM_MODAL_CONTENT_SELECTOR = '.modal-content-content';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shallowMount, mount } from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import ModalDialog from '@/presentation/components/Shared/Modal/ModalDialog.vue';
|
||||
import ModalContainer from '@/presentation/components/Shared/Modal/ModalContainer.vue';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import ModalOverlay from '@/presentation/components/Shared/Modal/ModalOverlay.vue';
|
||||
|
||||
const DOM_MODAL_OVERLAY_BACKGROUND_SELECTOR = '.modal-overlay-background';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { throttle, ITimer, TimeoutType } from '@/presentation/components/Shared/Throttle';
|
||||
import { EventSource } from '@/infrastructure/Events/EventSource';
|
||||
import { IEventSubscription } from '@/infrastructure/Events/IEventSource';
|
||||
|
||||
Reference in New Issue
Block a user