Skip to content

Commit

Permalink
Merge pull request #4108 from getkirby/feature/vitest-ci
Browse files Browse the repository at this point in the history
Vitest optimizations and CI integration
  • Loading branch information
bastianallgeier committed Jan 24, 2022
2 parents 1699cde + df81a1f commit 1b57037
Show file tree
Hide file tree
Showing 36 changed files with 59 additions and 13 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,18 @@ jobs:

- name: Run JavaScript unit tests
if: always() && steps.finishPrepare.outcome == 'success'
run: npm run test:unit
run: npm run test:unit:coverage
working-directory: panel

# TODO: Disabled until Vitest coverage reporting is accurate and
# Kirby's frontend tests are useful enough that we need this metric
# - name: Upload coverage results to Codecov
# uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # pin@v2
# with:
# token: ${{ secrets.CODECOV_TOKEN }} # for better reliability if the GitHub API is down
# fail_ci_if_error: true
# files: ${{ github.workspace }}/panel/coverage/lcov.info
# flags: frontend

frontend-e2e:
name: "Frontend: E2E tests"
Expand Down
8 changes: 1 addition & 7 deletions panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,5 @@
"last 2 Opera versions",
"last 2 OperaMobile versions",
"last 2 UCAndroid versions"
],
"c8": {
"skip-full": true,
"exclude": [
"vite.config.js"
]
}
]
}
3 changes: 2 additions & 1 deletion panel/src/components/Misc/Progress.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { describe, expect, it } from "vitest";
import { mount } from "@vue/test-utils";
import Progress from "./Progress.vue";

describe("Progress.vue", () => {
describe.concurrent("Progress.vue", () => {
it("mounts component", async () => {
const wrapper = mount(Progress);
expect(wrapper.element.value).toBe(0);
Expand Down
3 changes: 2 additions & 1 deletion panel/src/components/Misc/Text.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { describe, expect, it } from "vitest";
import { mount } from "@vue/test-utils";
import Text from "./Text.vue";

describe("Text.vue", () => {
describe.concurrent("Text.vue", () => {
it("has default slot", async () => {
const wrapper = mount(Text, {
slots: {
Expand Down
3 changes: 2 additions & 1 deletion panel/src/components/Navigation/PrevNext.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { describe, expect, it } from "vitest";
import { mount } from "@vue/test-utils";
import PrevNext from "./PrevNext.vue";

const setup = {
stubs: ["k-button-group"]
};

describe("PrevNext.vue", () => {
describe.concurrent("PrevNext.vue", () => {
it("has buttons", async () => {
const wrapper = mount(PrevNext, {
propsData: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1

exports[`PrevNext.vue > has buttons 1`] = `
exports[`PrevNext.vue > has CSS selector 1`] = `
<k-button-group-stub
buttons="[object Object],[object Object]"
class="k-prev-next"
Expand Down
1 change: 1 addition & 0 deletions panel/src/fiber/dialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import dialog from "./dialog.js";

const Vue = () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/fiber/dropdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import dropdown from "./dropdown.js";

describe.concurrent("$dropdown()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/fiber/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment jsdom
*/

import { describe, expect, it } from "vitest";
import Fiber from "./index.js";

describe.concurrent("$fiber", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/fiber/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import search from "./search.js";

describe.concurrent("$search()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/color.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import color from "./color.js";

describe.concurrent("$helper.css.color()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/embed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import embed from "./embed.js";

describe.concurrent("$helper.embed()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/object.clone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import { clone } from "./object.js";

describe.concurrent("$helper.object.clone()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/object.merge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import { merge } from "./object.js";

describe("$helper.object.merge", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/ratio.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import ratio from "./ratio.js";

describe.concurrent("$helper.ratio()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/sort.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import sort from "./sort.js";

describe.concurrent("$helper.sort()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.camelToKebab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import string from "./string.js";

describe.concurrent("$helper.string.camelToKebab", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.escapeHTML.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import string from "./string.js";

describe.concurrent("$helper.string.escapeHTML", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.hasEmoji.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import string from "./string.js";

describe.concurrent("$helper.string.hasEmoji", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.lcfirst.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import string from "./string.js";

describe.concurrent("$helper.string.lcfirst", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.pad.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import { pad } from "./string.js";

describe.concurrent("$helper.string.pad()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.random.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import string from "./string.js";

describe("$helper.string.random", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.slug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import { slug } from "./string.js";

describe.concurrent("$helper.string.slug()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.stripHTML.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import string from "./string.js";

describe("$helper.string.stripHTML", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import string from "./string.js";

describe.concurrent("$helper.string.template", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.ucfirst.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import string from "./string.js";

describe.concurrent("$helper.string.ucfirst", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.ucwords.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import string from "./string.js";

describe("$helper.string.ucwords", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/helpers/string.uuid.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import string from "./string.js";

describe("$helper.string.uuid", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/libraries/dayjs-iso.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import dayjs from "./dayjs.js";

describe("dayjs.iso()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/libraries/dayjs-merge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import dayjs from "./dayjs.js";

describe.concurrent("dayjs.merge()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/libraries/dayjs-pattern.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import dayjs from "./dayjs.js";

describe.concurrent("dayjs.pattern.at()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/libraries/dayjs-round.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import dayjs from "./dayjs.js";

describe.concurrent("dayjs.round()", () => {
Expand Down
1 change: 1 addition & 0 deletions panel/src/libraries/dayjs-units.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import dayjs from "./dayjs.js";

const data = {
Expand Down
1 change: 1 addition & 0 deletions panel/src/libraries/dayjs-validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vitest-environment node
*/

import { describe, expect, it } from "vitest";
import dayjs from "./dayjs.js";

describe.concurrent("dayjs.validate()", () => {
Expand Down
9 changes: 8 additions & 1 deletion panel/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ export default defineConfig(({ command }) => {
test: {
environment: "jsdom",
include: ["**/*.test.js"],
global: true
coverage: {
all: true,
exclude: ["**/*.e2e.js", "**/*.test.js"],
extension: ["js", "vue"],
src: "src",
reporter: ["text", "lcov"]
},
setupFiles: ["vitest.setup.js"]
}
};
});
4 changes: 4 additions & 0 deletions panel/vitest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Vue from "vue";

Vue.config.productionTip = false;
Vue.config.devtools = false;

0 comments on commit 1b57037

Please sign in to comment.