Skip to content

Commit f742a09

Browse files
committed
environment tests
1 parent e580dba commit f742a09

15 files changed

+5885
-646
lines changed

packages/react-to-web-component/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
"prettier": "prettier --check vite.config.ts src",
3636
"depcheck": "depcheck .",
3737
"dev": "vite",
38-
"test": "vitest",
39-
"test:ci": "vitest run",
38+
"test": "npm run test-environments",
39+
"test-environments": "cd ../../tests && npm run test-environments",
40+
"test:ci": "npm run test-environments",
4041
"test:coverage": "vitest run --coverage",
4142
"clean": "rm -rf tsconfig.tsbuildinfo dist",
4243
"build": "vite build"

tests/buildtests

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
#!/bin/bash
22

3-
cd src/tests/environments/react16
3+
cd environments/react16
44
node copyTest.js
5-
npm i
6-
npm install --install-links ../../../..
7-
cd ../../../../
5+
npm ci
6+
cd ../../
87

9-
cd src/tests/environments/react17
8+
cd environments/react17
109
node copyTest.js
11-
npm i
12-
npm install --install-links ../../../..
13-
cd ../../../../
10+
npm ci
11+
cd ../../
1412

15-
cd src/tests/environments/react18
13+
cd environments/react18
1614
node copyTest.js
17-
npm i
18-
npm install --install-links ../../../..
19-
cd ../../../../
15+
npm ci
16+
cd ../../
2017

2118
# cd src/tests/environments/preact10
2219
# npm i
@@ -25,15 +22,15 @@ cd ../../../../
2522

2623

2724
# builds
28-
cd src/tests/builds/vite
29-
npm i
30-
npm install --install-links ../../../..
31-
npm run build
32-
node swcBuild.js
33-
cd ../../../../
25+
# cd src/tests/builds/vite
26+
# npm i
27+
# npm install --install-links ../../../..
28+
# npm run build
29+
# node swcBuild.js
30+
# cd ../../../../
3431

35-
cd src/tests/builds/webpack
36-
npm i
37-
npm install --install-links ../../../..
38-
npm run build
39-
cd ../../../../
32+
# cd src/tests/builds/webpack
33+
# npm i
34+
# npm install --install-links ../../../..
35+
# npm run build
36+
# cd ../../../../
+7-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
const fs = require("fs")
33

4-
const TEST_PATH = "../../react-to-webcomponent.test.jsx"
5-
const REACT16_TEST_PATH = "./react-to-webcomponent.test.jsx"
4+
const TEST_PATH = "../../react-to-web-component.test.tsx"
5+
const REACT16_TEST_PATH = "./react-to-web-component.test.tsx"
66

77
// copy test file from tests folder to react16 folder
88
fs.copyFileSync(TEST_PATH, REACT16_TEST_PATH)
99

10-
// edit react-to-webcomponent test file's reactToWebComponent and components imports
10+
// read test file
1111
const data = fs.readFileSync(REACT16_TEST_PATH, "utf8")
12-
const result = data.replace(/..\/legacy\/react-to-webcomponent/g, "react-to-webcomponent/render")
13-
const result2 = result.replace(/.\/components/g, "../../components.tsx")
12+
// add react-to-web-component import to top of file
13+
const result = `import r2wc from '@r2wc/react-to-web-component';\n${data}`
14+
// remove r2wc mock from test file
15+
const result2 = result.replace("const r2wc = vi.fn()", "")
1416
fs.writeFileSync(REACT16_TEST_PATH, result2, "utf8")

0 commit comments

Comments
 (0)