Skip to content

Commit a5c5af0

Browse files
authored
Fix standalone test (#2211)
* Run standalone test on CI * Fix test * Update yarn.lock
1 parent accc09e commit a5c5af0

File tree

4 files changed

+32
-46
lines changed

4 files changed

+32
-46
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
node-version: [14.x, 16.x, 18.x, 20.x]
1313

1414
steps:
15-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v3
1616
- name: Use Node.js ${{ matrix.node-version }}
17-
uses: actions/setup-node@v1
17+
uses: actions/setup-node@v3
1818
with:
1919
node-version: ${{ matrix.node-version }}
2020
- name: yarn install, build, and test

jest.config.js

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
const ENABLE_COVERAGE = !!process.env.CI;
4+
const RUN_STANDALONE_TESTS = Boolean(process.env.RUN_STANDALONE_TESTS);
45

56
module.exports = {
67
collectCoverage: ENABLE_COVERAGE,
@@ -10,34 +11,31 @@ module.exports = {
1011
"!<rootDir>/tests_config/",
1112
],
1213
projects: [
13-
{
14-
displayName: "test-node",
15-
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
16-
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
17-
snapshotSerializers: ["jest-snapshot-serializer-raw"],
18-
testEnvironment: "node",
19-
globals: {
20-
STANDALONE: false,
21-
},
22-
runner: "jest-light-runner",
23-
transform: {},
24-
},
25-
...(/^true$/i.test(process.env.RUN_STANDALONE_TESTS)
26-
? [
27-
{
28-
displayName: "test-standalone",
29-
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
30-
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
31-
snapshotSerializers: ["jest-snapshot-serializer-raw"],
32-
testEnvironment: "jsdom",
33-
globals: {
34-
STANDALONE: true,
35-
},
36-
runner: "jest-light-runner",
37-
transform: {},
14+
RUN_STANDALONE_TESTS
15+
? {
16+
displayName: "test-standalone",
17+
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
18+
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
19+
snapshotSerializers: ["jest-snapshot-serializer-raw"],
20+
testEnvironment: "jsdom",
21+
globals: {
22+
STANDALONE: true,
23+
},
24+
runner: "jest-light-runner",
25+
transform: {},
26+
}
27+
: {
28+
displayName: "test-node",
29+
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
30+
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
31+
snapshotSerializers: ["jest-snapshot-serializer-raw"],
32+
testEnvironment: "node",
33+
globals: {
34+
STANDALONE: false,
3835
},
39-
]
40-
: []),
36+
runner: "jest-light-runner",
37+
transform: {},
38+
},
4139
{
4240
runner: "jest-runner-eslint",
4341
displayName: "lint",

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@
4040
"rollup-plugin-node-resolve": "^5.2.0",
4141
"rollup-plugin-replace": "^2.1.0",
4242
"rollup-plugin-terser": "^7.0.2",
43-
"strip-ansi": "^6.0.0",
44-
"yarpm": "^1.1.1"
43+
"strip-ansi": "^6.0.0"
4544
},
4645
"peerDependencies": {
4746
"prettier": "^3.0.0"
4847
},
4948
"scripts": {
50-
"test": "jest",
51-
"prepublishOnly": "yarpm run build-standalone && cross-env RUN_STANDALONE_TESTS=true yarpm test",
49+
"test": "yarn test:node && yarn test:standalone",
50+
"test:node": "jest",
51+
"test:standalone": "yarn run build-standalone && cross-env RUN_STANDALONE_TESTS=true yarn jest",
52+
"prepublishOnly": "yarn test",
5253
"prettier": "prettier --plugin=src/index.js --parser=php",
5354
"build-standalone": "rollup -c build/rollup.config.js",
5455
"debug": "node --inspect-brk node_modules/.bin/jest --runInBand"

yarn.lock

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,11 +2450,6 @@ combined-stream@^1.0.8:
24502450
dependencies:
24512451
delayed-stream "~1.0.0"
24522452

2453-
command-exists@^1.2.9:
2454-
version "1.2.9"
2455-
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69"
2456-
integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==
2457-
24582453
commander@^2.20.0:
24592454
version "2.20.3"
24602455
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
@@ -5979,14 +5974,6 @@ yargs@^17.3.1:
59795974
y18n "^5.0.5"
59805975
yargs-parser "^21.0.0"
59815976

5982-
yarpm@^1.1.1:
5983-
version "1.2.0"
5984-
resolved "https://registry.yarnpkg.com/yarpm/-/yarpm-1.2.0.tgz#5baaf5589f6237426cf76f812296dcf9b4254f55"
5985-
integrity sha512-gxN4Ali09uey8EpLfbYG+bTXf1hF6TA5oAXFPpKi5Nt5aztXU9AIEksXE0lpuvC50vL4De/KIeP8JXgYOZ8KbQ==
5986-
dependencies:
5987-
command-exists "^1.2.9"
5988-
cross-spawn "^7.0.3"
5989-
59905977
yocto-queue@^0.1.0:
59915978
version "0.1.0"
59925979
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"

0 commit comments

Comments
 (0)