Add tests for release script (#11454)

* Install jest

* Configure jest script

* Fix eslintrc

* Add @types/jest

* Add test for validate-new-version

* Fix eslintrc

* Add workflow file

* Add node version

* cd to script/release

* Fix workflow file

* Fix version

* Ignore from root

* Update yarn.lock

* Set defaults.run.working-directory
This commit is contained in:
Sosuke Suzuki authored and GitHub committed 2021-09-07 14:53:45 +09:00
1 parent 2bbe331f64
commit bf2a24fdd1
8 files changed
+2454 -23

No files matched your search

+1
View File
@@ -153,6 +153,7 @@ module.exports = {
"tests/format/**/jsfmt.spec.js",
"tests/config/**/*.js",
"tests/integration/**/*.js",
"scripts/release/__tests__/**/*.spec.js",
],
env: {
jest: true,
+35
View File
@@ -0,0 +1,35 @@
name: Release_Script_Test
defaults:
run:
working-directory: scripts/release
on:
push:
paths:
- "scripts/release/**"
- ".github/workflows/release-script-test.yml"
pull_request:
paths:
- "scripts/release/**"
- ".github/workflows/release-script-test.yml"
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Setup Node.js
uses: actions/setup-node@v2.4.0
with:
version: "14"
cache: "yarn"
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Test
run: yarn test
+5 -1
View File
@@ -71,7 +71,11 @@ module.exports = {
"prettier-local": "<rootDir>/tests/config/require-prettier.js",
"prettier-standalone": "<rootDir>/tests/config/require-standalone.js",
},
modulePathIgnorePatterns: ["<rootDir>/dist", "<rootDir>/website"],
modulePathIgnorePatterns: [
"<rootDir>/dist",
"<rootDir>/website",
"<rootDir>/scripts/release",
],
transform,
watchPlugins: [
"jest-watch-typeahead/filename",
+1
View File
@@ -98,6 +98,7 @@
"@rollup/plugin-node-resolve": "13.0.4",
"@rollup/plugin-replace": "3.0.0",
"@types/estree": "0.0.50",
"@types/jest": "27.0.1",
"babel-jest": "27.1.0",
"babel-loader": "8.2.2",
"benchmark": "2.1.4",
@@ -0,0 +1,15 @@
import chalk from "chalk";
import step from "../../steps/validate-new-version.js";
describe("validate-new-version", () => {
it("throws error for invalid semver", () => {
expect(() => {
step({ version: "foo" });
}).toThrow("Invalid version specified");
});
it("throws error when version isn't greater than prev version", () => {
expect(() => {
step({ version: "0.0.1", previousVersion: "0.0.2" });
}).toThrow(`Version ${chalk.yellow("0.0.1")} has already been published`);
});
});
+6
View File
@@ -1,6 +1,9 @@
{
"private": true,
"type": "module",
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"dependencies": {
"chalk": "4.1.2",
"execa": "5.1.1",
@@ -9,5 +12,8 @@
"outdent": "0.8.0",
"semver": "7.3.5",
"string-width": "5.0.0"
},
"devDependencies": {
"jest": "27.1.0"
}
}
+2352 -16
View File
File diff suppressed because it is too large. Load diff
+39 -6
View File
@@ -1415,7 +1415,7 @@
source-map "^0.6.1"
write-file-atomic "^3.0.0"
"@jest/types@^27.1.0":
"@jest/types@^27.0.2", "@jest/types@^27.1.0":
version "27.1.0"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.1.0.tgz#674a40325eab23c857ebc0689e7e191a3c5b10cc"
integrity sha512-pRP5cLIzN7I7Vp6mHKRSaZD7YpBTK7hawx5si8trMKqk4+WOdK8NEKOTO2G8PKWD1HbKMVckVB6/XHh/olhf2g==
@@ -1634,7 +1634,20 @@
dependencies:
"@types/istanbul-lib-report" "*"
"@types/json-schema@*", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.7", "@types/json-schema@^7.0.8":
"@types/jest@27.0.1":
version "27.0.1"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.0.1.tgz#fafcc997da0135865311bb1215ba16dba6bdf4ca"
integrity sha512-HTLpVXHrY69556ozYkcq47TtQJXpcWAWfkoqz+ZGz2JnmZhzlRjprCIyFnetSy8gpDWwTTGBcRVv1J1I1vBrHw==
dependencies:
jest-diff "^27.0.0"
pretty-format "^27.0.0"
"@types/json-schema@*", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.7":
version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
"@types/json-schema@^7.0.8":
version "7.0.9"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
@@ -2720,7 +2733,7 @@ detect-newline@^3.0.0:
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==
diff-sequences@^27.0.6:
diff-sequences@^27.0.1, diff-sequences@^27.0.6:
version "27.0.6"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.0.6.tgz#3305cb2e55a033924054695cc66019fd7f8e5723"
integrity sha512-ag6wfpBFyNXZ0p8pcuIDS//D8H062ZQJ3fzYxjpmeKjnz8W4pekL3AI8VohmyZmsWW2PWaHgjsmqR6L13101VQ==
@@ -4000,7 +4013,7 @@ jest-config@^27.1.0:
micromatch "^4.0.4"
pretty-format "^27.1.0"
jest-diff@^27.0.2, jest-diff@^27.1.0:
jest-diff@^27.0.0, jest-diff@^27.1.0:
version "27.1.0"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.1.0.tgz#c7033f25add95e2218f3c7f4c3d7b634ab6b3cd2"
integrity sha512-rjfopEYl58g/SZTsQFmspBODvMSytL16I+cirnScWTLkQVXYVZfxm78DFfdIIXc05RCYuGjxJqrdyG4PIFzcJg==
@@ -4010,6 +4023,16 @@ jest-diff@^27.0.2, jest-diff@^27.1.0:
jest-get-type "^27.0.6"
pretty-format "^27.1.0"
jest-diff@^27.0.2:
version "27.0.2"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.0.2.tgz#f315b87cee5dc134cf42c2708ab27375cc3f5a7e"
integrity sha512-BFIdRb0LqfV1hBt8crQmw6gGQHVDhM87SpMIZ45FPYKReZYG5er1+5pIn2zKqvrJp6WNox0ylR8571Iwk2Dmgw==
dependencies:
chalk "^4.0.0"
diff-sequences "^27.0.1"
jest-get-type "^27.0.1"
pretty-format "^27.0.2"
jest-docblock@27.0.6, jest-docblock@^27.0.6:
version "27.0.6"
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-27.0.6.tgz#cc78266acf7fe693ca462cbbda0ea4e639e4e5f3"
@@ -4053,7 +4076,7 @@ jest-environment-node@^27.1.0:
jest-mock "^27.1.0"
jest-util "^27.1.0"
jest-get-type@^27.0.6:
jest-get-type@^27.0.1, jest-get-type@^27.0.6:
version "27.0.6"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.0.6.tgz#0eb5c7f755854279ce9b68a9f1a4122f69047cfe"
integrity sha512-XTkK5exIeUbbveehcSR8w0bhH+c0yloW/Wpl+9vZrjzztCPWrxhHwkIFpZzCt71oRBsgxmuUfxEqOYoZI2macg==
@@ -5228,7 +5251,7 @@ pretty-bytes@5.6.0:
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb"
integrity sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==
pretty-format@^27.0.2, pretty-format@^27.1.0:
pretty-format@^27.0.0, pretty-format@^27.1.0:
version "27.1.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.1.0.tgz#022f3fdb19121e0a2612f3cff8d724431461b9ca"
integrity sha512-4aGaud3w3rxAO6OXmK3fwBFQ0bctIOG3/if+jYEFGNGIs0EvuidQm3bZ9mlP2/t9epLNC/12czabfy7TZNSwVA==
@@ -5238,6 +5261,16 @@ pretty-format@^27.0.2, pretty-format@^27.1.0:
ansi-styles "^5.0.0"
react-is "^17.0.1"
pretty-format@^27.0.2:
version "27.0.2"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.0.2.tgz#9283ff8c4f581b186b2d4da461617143dca478a4"
integrity sha512-mXKbbBPnYTG7Yra9qFBtqj+IXcsvxsvOBco3QHxtxTl+hHKq6QdzMZ+q0CtL4ORHZgwGImRr2XZUX2EWzORxig==
dependencies:
"@jest/types" "^27.0.2"
ansi-regex "^5.0.0"
ansi-styles "^5.0.0"
react-is "^17.0.1"
progress@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"