Skip to content

Commit 5578dec

Browse files
committed
fix: api headless cms tests
1 parent a5b71ef commit 5578dec

File tree

102 files changed

+493
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+493
-273
lines changed

.eslintrc.cjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function getNoUnusedVars() {
99
module.exports = {
1010
extends: [
1111
"plugin:@typescript-eslint/recommended",
12-
"plugin:jest/recommended",
12+
"plugin:@vitest/legacy-recommended",
1313
"plugin:react/recommended"
1414
],
1515
parser: "@typescript-eslint/parser",
@@ -18,9 +18,8 @@ module.exports = {
1818
tsconfigRootDir: __dirname,
1919
sourceType: "module"
2020
},
21-
plugins: ["@typescript-eslint", "jest", "import", "react", "lodash"],
21+
plugins: ["@typescript-eslint", "@vitest", "import", "react", "lodash"],
2222
env: {
23-
jest: true,
2423
commonjs: true,
2524
node: true,
2625
es6: true
@@ -59,12 +58,12 @@ module.exports = {
5958
// Temporarily disable this rule
6059
"@typescript-eslint/no-non-null-assertion": 0,
6160
curly: ["error"],
62-
"jest/expect-expect": 0,
61+
"@vitest/expect-expect": 0,
6362
// Sometimes we have to use expect() inside try/catch clause (for async calls).
6463
// This rule raises an error when you do that, so we disabled it.
65-
"jest/no-conditional-expect": 0,
66-
"jest/no-commented-out-tests": 0,
67-
"jest/no-disabled-tests": 0,
64+
"@vitest/no-conditional-expect": 0,
65+
"@vitest/no-commented-out-tests": 0,
66+
"@vitest/no-disabled-tests": 0,
6867
"lodash/import-scope": [2, "method"],
6968
"no-restricted-imports": [
7069
"error",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@types/react-dom": "18.2.25",
6363
"@typescript-eslint/eslint-plugin": "^6.21.0",
6464
"@typescript-eslint/parser": "^6.21.0",
65+
"@vitest/eslint-plugin": "^1.3.9",
6566
"adio": "^2.0.1",
6667
"axios": "^1.8.2",
6768
"babel-loader": "^9.2.1",

packages/api-headless-cms/__tests__/contentAPI/aco/acoGraphQl.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
import { describe, it, expect } from "vitest";
12
import { useGraphQLHandler } from "./setup/useGraphQLHandler";
23
import { ROOT_FOLDER } from "~/constants";
3-
import { jest } from "@jest/globals";
4-
5-
jest.retryTimes(0);
64

75
const entryId = `custom-entry-id`;
86
const id = `${entryId}#0001`;

packages/api-headless-cms/__tests__/contentAPI/benchmark.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { describe, it, expect, beforeEach, vi } from "vitest";
12
import { useGraphQLHandler } from "~tests/testHelpers/useGraphQLHandler";
23
import { ContextPlugin } from "@webiny/api";
3-
import { jest } from "@jest/globals";
44

55
describe("benchmark points", () => {
66
let elapsed = 0;
@@ -23,7 +23,7 @@ describe("benchmark points", () => {
2323

2424
it("should run benchmark and have required points present in the log", async () => {
2525
const logs: any[] = [];
26-
jest.spyOn(console, "log").mockImplementation((...args) => {
26+
vi.spyOn(console, "log").mockImplementation((...args) => {
2727
logs.push(...args);
2828
});
2929

packages/api-headless-cms/__tests__/contentAPI/cmsEndpointAccess.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { CmsGroup, CmsModel } from "~/types";
23
import { useGraphQLHandler } from "../testHelpers/useGraphQLHandler";
34
import { useCategoryManageHandler } from "../testHelpers/useCategoryManageHandler";
@@ -86,7 +87,7 @@ describe("Endpoint access", () => {
8687
}
8788
};
8889

89-
test(`user has access to manage endpoint`, async () => {
90+
it(`user has access to manage endpoint`, async () => {
9091
await setupContentModel();
9192
const { listCategories } = useCategoryManageHandler({
9293
...manageOpts,
@@ -115,7 +116,7 @@ describe("Endpoint access", () => {
115116
});
116117
});
117118

118-
test(`user does not have access to manage endpoint`, async () => {
119+
it(`user does not have access to manage endpoint`, async () => {
119120
await setupContentModel();
120121
const { listCategories } = useCategoryManageHandler({
121122
...manageOpts,
@@ -144,7 +145,7 @@ describe("Endpoint access", () => {
144145
});
145146
});
146147

147-
test(`user has access to read endpoint`, async () => {
148+
it(`user has access to read endpoint`, async () => {
148149
await setupContentModel();
149150
const { listCategories } = useCategoryReadHandler({
150151
...readOpts,
@@ -173,7 +174,7 @@ describe("Endpoint access", () => {
173174
});
174175
});
175176

176-
test(`user does not have access to read endpoint`, async () => {
177+
it(`user does not have access to read endpoint`, async () => {
177178
await setupContentModel();
178179
const { listCategories } = useCategoryReadHandler({
179180
...readOpts,
@@ -203,7 +204,7 @@ describe("Endpoint access", () => {
203204
});
204205
});
205206

206-
test(`user has access to preview endpoint`, async () => {
207+
it(`user has access to preview endpoint`, async () => {
207208
await setupContentModel();
208209
const { listCategories } = useCategoryReadHandler({
209210
...previewOpts,
@@ -232,7 +233,7 @@ describe("Endpoint access", () => {
232233
});
233234
});
234235

235-
test(`user does not have access to preview endpoint`, async () => {
236+
it(`user does not have access to preview endpoint`, async () => {
236237
await setupContentModel();
237238
const { listCategories } = useCategoryReadHandler({
238239
...previewOpts,

packages/api-headless-cms/__tests__/contentAPI/cmsEntryStatus.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { beforeEach, describe, expect, it } from "vitest";
12
import { useCategoryManageHandler } from "../testHelpers/useCategoryManageHandler";
23
import camelCase from "lodash/camelCase";
34
import { CmsGroup } from "~/types";

packages/api-headless-cms/__tests__/contentAPI/cmsEntryValidation/contentEntry.crud.validation.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import { useValidationManageHandler } from "./handler";
23
import ucFirst from "lodash/upperFirst";
34
import camelCase from "lodash/camelCase";

packages/api-headless-cms/__tests__/contentAPI/cmsEntryValidation/contentEntry.optionalValidation.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import { createValidationStructure } from "~tests/contentAPI/cmsEntryValidation/mocks/structure";
23
import { useValidationManageHandler } from "~tests/contentAPI/cmsEntryValidation/handler";
34
import {

packages/api-headless-cms/__tests__/contentAPI/cmsEntryValidation/mocks/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect } from "vitest";
12
import { CmsDynamicZoneTemplate, CmsModelFieldInput } from "~/types";
23

34
const nestedErrorRegex = /^(nested|dz)([A-Za-z]+)$/;

packages/api-headless-cms/__tests__/contentAPI/contentEntries.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { useFruitManageHandler } from "../testHelpers/useFruitManageHandler";
23
import { Fruit } from "./mocks/contentModels";
34
import { setupContentModelGroup, setupContentModels } from "../testHelpers/setup";

0 commit comments

Comments
 (0)