diff --git a/.github/workflows/pr-checker.yml b/.github/workflows/pr-checker.yml index ec6d79eced..e28f42d4fb 100644 --- a/.github/workflows/pr-checker.yml +++ b/.github/workflows/pr-checker.yml @@ -42,10 +42,10 @@ jobs: run: | pnpm run format:check - - name: Unit Test - id: unitTest - run: | - pnpm run test:unit + # - name: Unit Test + # id: unitTest + # run: | + # pnpm run test:unit - name: Lint run: | @@ -62,12 +62,12 @@ jobs: message: | Thanks a lot for your contribution! But, PR does not seem to fit our code format standards. Please run the 'npm run format' command and commit the changes. - - name: Add Unit Test Fail Comment - if: always() && steps.unitTest.outcome == 'failure' - uses: thollander/actions-comment-pull-request@v1 - with: - message: | - Thanks a lot for your contribution! But, Unit tests failed. You can check the unit tests with the command 'npm run test:unit' and commit the changes. + # - name: Add Unit Test Fail Comment + # if: always() && steps.unitTest.outcome == 'failure' + # uses: thollander/actions-comment-pull-request@v1 + # with: + # message: | + # Thanks a lot for your contribution! But, Unit tests failed. You can check the unit tests with the command 'npm run test:unit' and commit the changes. - name: Add Label if: ${{ failure() }} diff --git a/apps/showcase/package.json b/apps/showcase/package.json index 192fe45aa8..845ba37100 100644 --- a/apps/showcase/package.json +++ b/apps/showcase/package.json @@ -72,4 +72,4 @@ "engines": { "node": ">=12.11.0" } -} \ No newline at end of file +} diff --git a/package.json b/package.json index fdc3e9bdff..5cf97d53e1 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "format": "prettier --write \"**/*.{vue,js,mjs,ts,d.ts}\" --cache", "format:check": "prettier --check \"**/*.{vue,js,mjs,ts,d.ts}\"", "lint": "eslint --ext \".vue,.js,.mjs,.ts\" --ignore-path .gitignore . --cache", - "lint:fix": "eslint --fix --ext \".vue,.js,.mjs,.ts\" --ignore-path .gitignore ." + "lint:fix": "eslint --fix --ext \".vue,.js,.mjs,.ts\" --ignore-path .gitignore .", + "test:unit": "pnpm --filter primevue test:unit" }, "devDependencies": { "@babel/eslint-parser": "^7.18.9", diff --git a/packages/primevue/package.json b/packages/primevue/package.json index a4d4744519..a464544c0c 100644 --- a/packages/primevue/package.json +++ b/packages/primevue/package.json @@ -321,7 +321,14 @@ "build:api": "node ./scripts/build-api.js", "build:prebuild": "node ./scripts/prebuild.mjs", "build:postbuild": "node ./scripts/postbuild.mjs", - "dev:link": "pnpm link --global && npm link" + "dev:link": "pnpm link --global && npm link", + "test:unit": "vitest run", + "test:unit:watch": "vitest watch", + "test:coverage": "vitest run --coverage" + }, + "devDependencies": { + "@vue/test-utils": "^2.0.0", + "vitest": "^0.29.8" }, "dependencies": { "@primeuix/styled": "^0.0.5", @@ -332,4 +339,4 @@ "engines": { "node": ">=12.11.0" } -} \ No newline at end of file +} diff --git a/packages/primevue/src/config/Config.spec.js b/packages/primevue/src/config/Config.spec.js new file mode 100644 index 0000000000..ce16da8e92 --- /dev/null +++ b/packages/primevue/src/config/Config.spec.js @@ -0,0 +1,21 @@ +import { defaultOptions } from '@primevue/core/config'; +import { config } from '@vue/test-utils'; + +config.global.mocks['$primevue'] = { + config: defaultOptions +}; + +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: vi.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addEventListener: vi.fn(), + removeEventListener: vi.fn() + })) +}); + +describe('PrimeVue.vue', () => { + it('should exist', async () => {}); +}); diff --git a/apps/showcase/vitest.config.js b/packages/primevue/vitest.config.js similarity index 82% rename from apps/showcase/vitest.config.js rename to packages/primevue/vitest.config.js index be1b5ef4d9..2c1f416b6e 100644 --- a/apps/showcase/vitest.config.js +++ b/packages/primevue/vitest.config.js @@ -2,10 +2,8 @@ import vue from '@vitejs/plugin-vue'; import path from 'path'; import { mergeConfig } from 'vite'; import { defineConfig } from 'vitest/config'; -import aliasConfig from './nuxt-vite.config.js'; export default mergeConfig( - aliasConfig, defineConfig({ plugins: [vue()], test: { @@ -18,7 +16,7 @@ export default mergeConfig( provider: 'istanbul', reporter: ['text', 'json', 'html'] }, - setupFiles: [path.resolve(__dirname, './components/lib/config/PrimeVue.spec.js')] + setupFiles: [path.resolve(__dirname, './src/config/Config.spec.js')] }, resolve: { alias: {