mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-14 10:06:04 +08:00
- Introduce test targets. - Adding additional tests. Related to: https://github.com/harvester/harvester/issues/11892 Signed-off-by: Volker Theile <vtheile@suse.com>
1.1 KiB
1.1 KiB
Unit Tests (Jest)
Unit and component tests run with Jest. The setup follows the Rancher dashboard and the Rancher extension template (rancher/ui-plugin-examples), so both stay aligned.
- Run the tests in watch mode with
yarn test, all tests once withyarn test:ci, a single file withyarn test <path>. CI runsyarn test:cion every pull request. - Test files live next to the code in
__tests__folders and are named<name>.test.jsor<name>.test.ts. - Configuration:
jest.config.js: environment, module aliases (@shell,@components,@pkg) and transforms.jest.setup.js: global mocks (t,$store, common directives) and browser APIs that jsdom does not provide.vue3JestRegisterTs.js: makes TypeScript available to the Vue compiler, otherwise.vuefiles with typed props fail to compile.
- Components are tested with the Vue Test Utils 2 API: use
propsandglobal.mocks, not the Vue 2 optionspropsDataandmocks. - Models and utils can be tested without mounting anything, see
pkg/harvester/models/__tests__for examples.