Skip to content

Commit

Permalink
chore(deps): update jest monorepo to v28 (major) (#1456)
Browse files Browse the repository at this point in the history
* chore(deps): update jest monorepo to v28

* test: fix jest.config.js

From jestjs/jest#12689, jest passes `rootDir` option to babel-jest.
If rootDir is project sub-directory (e.g. `src/`, `__tests__/`),
babel cannot load babel.config.js in project root.

* chore(rest-api-client): fix type error for dom (#1513)

* test(create-plugin): fix jest.config.js

* chore(rest-api-client): add type definition of Blob and BlobPart

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Masaharu TASHIRO <[email protected]>
Co-authored-by: tasshi / Masaharu TASHIRO <[email protected]>
Co-authored-by: Masashi Hirano <[email protected]>
  • Loading branch information
5 people authored May 19, 2022
1 parent 29497f7 commit 5e00e66
Show file tree
Hide file tree
Showing 20 changed files with 736 additions and 842 deletions.
8 changes: 5 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
rootDir: "__tests__",
testPathIgnorePatterns: ["lib/"],
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
roots: ["<rootDir>/__tests__"],
testPathIgnorePatterns: ["<rootDir>/node_modules/", "lib/"],
};
module.exports = config;
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"initial:release": "lerna publish from-package --conventional-commits",
"prerelease": "npm-run-all -s build -p lint test",
"release": "lerna publish --conventional-commits --create-release github",
"pretest": "jest --rootDir __tests__",
"pretest": "jest",
"start": "yarn build --watch",
"test": "lerna run test --parallel",
"pretest:ci": "yarn pretest",
Expand All @@ -41,9 +41,10 @@
"@cybozu/eslint-config": "^17.0.1",
"@types/jest": "^27.5.1",
"@types/node": "^13.13.52",
"babel-jest": "^28.1.0",
"comment-json": "^4.2.2",
"eslint": "^8.15.0",
"jest": "^27.5.1",
"jest": "^28.1.0",
"lerna": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/create-plugin/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
testRegex: "/test/.*\\.ts$",
testEnvironment: "node",
testPathIgnorePatterns: ["node_modules"],
};
module.exports = config;
4 changes: 2 additions & 2 deletions packages/customize-uploader/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript"
]
"@babel/preset-typescript",
],
};
5 changes: 4 additions & 1 deletion packages/customize-uploader/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
roots: ["<rootDir>/src"],
testRegex: "/__tests__/.*\\.test\\.ts$",
testEnvironment: "node",
};
module.exports = config;
4 changes: 2 additions & 2 deletions packages/customize-uploader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"prebuild": "yarn clean",
"build": "tsc --build --force",
"lint": "eslint --ext .ts src",
"test": "jest --rootDir src",
"test:ci": "jest --rootDir src --runInBand",
"test": "jest",
"test:ci": "jest --runInBand",
"clean": "rimraf dist",
"start": "yarn build --watch"
},
Expand Down
8 changes: 5 additions & 3 deletions packages/data-loader/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
rootDir: "src",
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
roots: ["<rootDir>/src"],
clearMocks: true,
testPathIgnorePatterns: ["fixtures"],
testPathIgnorePatterns: ["<rootDir>/node_modules/", "fixtures"],
};
module.exports = config;
11 changes: 4 additions & 7 deletions packages/dts-gen/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{ targets: { node: "current" } },
],
"@babel/preset-typescript",
],
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
};
8 changes: 5 additions & 3 deletions packages/dts-gen/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
rootDir: "src",
testEnvironment: "node",
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
roots: ["<rootDir>/src"],
testEnvironment: "node",
};
module.exports = config;
7 changes: 4 additions & 3 deletions packages/plugin-manifest-validator/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
roots: ["<rootDir>/src"],
clearMocks: true,
rootDir: "src",
testPathIgnorePatterns: ["node_modules"],
testEnvironment: "node",
};
module.exports = config;
4 changes: 3 additions & 1 deletion packages/plugin-packer/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
testRegex: "(?<!site)/test/[^\\/]*\\.spec.ts$",
testEnvironment: "node",
testTimeout: 30000,
};
module.exports = config;
2 changes: 1 addition & 1 deletion packages/plugin-packer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"ajv": "^6.12.6",
"array-flatten": "^3.0.0",
"assert": "^2.0.0",
"babel-jest": "^27.5.1",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
Expand All @@ -67,6 +66,7 @@
"cssnano": "^5.1.8",
"execa": "^5.1.1",
"glob": "^7.2.3",
"jest-environment-jsdom": "^28.1.0",
"normalize.css": "^8.0.1",
"path-browserify": "^1.0.1",
"postcss": "^8.4.14",
Expand Down
4 changes: 3 additions & 1 deletion packages/plugin-packer/site/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
testRegex: "/test/.*-test\\.js$",
testEnvironment: "jsdom",
};
module.exports = config;
6 changes: 4 additions & 2 deletions packages/profile-loader/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
rootDir: "src",
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
roots: ["<rootDir>/src"],
testEnvironment: "node",
};
module.exports = config;
13 changes: 9 additions & 4 deletions packages/rest-api-client/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
clearMocks: true,
rootDir: "src",
setupFilesAfterEnv: ["<rootDir>/__tests__/setup.ts"],
testPathIgnorePatterns: ["node_modules", "<rootDir>/__tests__/setup.ts"],
roots: ["<rootDir>/src"],
setupFilesAfterEnv: ["<rootDir>/src/__tests__/setup.ts"],
testPathIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/src/__tests__/setup.ts",
],
testEnvironment: "node",
};
module.exports = config;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("KintoneRestAPIClient", () => {
getRequestToken: () => "dummy request token",
};
global.location = {
...global.location,
host: "example.com",
protocol: "https:",
};
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-api-client/src/platform/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const buildHeaders = () => {
};

export const buildFormDataValue = (data: unknown) => {
return new Blob([data]);
return new Blob([data as BlobPart]);
};

export const buildBaseUrl = (baseUrl?: string) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/rest-api-client/types/global/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ declare const location:
}
| undefined;

declare type BlobPart = unknown;

declare class Blob {
constructor(array: unknown[]);
constructor(array: BlobPart[]);
}

declare const PACKAGE_VERSION: string;
Expand Down
11 changes: 8 additions & 3 deletions packages/webpack-plugin-kintone-plugin/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module.exports = {
rootDir: "src",
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
roots: ["<rootDir>/src"],
testEnvironment: "node",
testPathIgnorePatterns: ["node_modules", "<rootDir>/__tests__/sample"],
testPathIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/src/__tests__/sample",
],
testTimeout: 30000,
};
module.exports = config;
Loading

0 comments on commit 5e00e66

Please sign in to comment.