Skip to content

Commit d63a1a2

Browse files
authored
test: improve typescript-based test framework (#12226)
1 parent 3fdcbf5 commit d63a1a2

File tree

9 files changed

+218
-29
lines changed

9 files changed

+218
-29
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
run: |
1717
pip install codespell==2.1.0
1818
# codespell considers some repo name in go.sum are misspelled
19-
git grep --cached -l '' | grep -v go.sum | grep -v pnpm-lock.yaml |xargs codespell --ignore-words=.ignore_words
19+
git grep --cached -l '' | grep -v go.sum | grep -v pnpm-lock.yaml |xargs codespell --ignore-words=.ignore_words --skip="*.ts,*.mts"
2020
- name: Merge conflict
2121
run: |
2222
bash ./utils/check-merge-conflict.sh

.licenserc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ header:
3232
- '**/*.crt'
3333
- '**/*.pem'
3434
- '**/*.pb.go'
35+
- '**/pnpm-lock.yaml'
3536
- '.github/'
3637
- 'conf/mime.types'
3738
- '**/*.svg'

t/jest.config.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
18-
import type {Config} from 'jest';
17+
import type { Config } from 'jest';
1918

2019
const config: Config = {
21-
coverageProvider: "v8",
22-
testEnvironment: "node",
20+
coverageProvider: 'v8',
21+
testEnvironment: 'node',
22+
testRegex: '(/__tests__/.*|(\\.|/)(spec|test))\\.(ts|mts)$',
2323
transform: {
24-
"^.+\.tsx?$": ["ts-jest",{}],
24+
'^.+\\.ts$': ['ts-jest', { useESM: false }],
25+
'^.+\\.mts$': ['ts-jest', { useESM: true, tsconfig: 'tsconfig.esm.json' }],
2526
},
27+
extensionsToTreatAsEsm: ['.mts'],
28+
moduleFileExtensions: ['ts', 'mts', 'js'],
2629
};
2730

2831
export default config;

t/package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
{
22
"name": "apisix-test-suite",
33
"private": true,
4+
"type": "module",
45
"scripts": {
5-
"test": "jest"
6+
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
67
},
78
"devDependencies": {
9+
"@jest/globals": "^29.7.0",
10+
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
811
"@types/jest": "29.5.14",
912
"@types/node": "22.14.1",
1013
"axios": "^1.9.0",
14+
"docker-compose": "^1.2.0",
15+
"graphql": "^16.11.0",
16+
"graphql-request": "^7.1.2",
1117
"jest": "29.7.0",
18+
"lago-javascript-client": "^1.26.0",
19+
"simple-git": "^3.27.0",
1220
"ts-jest": "29.3.2",
1321
"ts-node": "10.9.2",
1422
"yaml": "^2.7.1"
15-
}
23+
},
24+
"packageManager": "[email protected]+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
1625
}

t/pnpm-lock.yaml

Lines changed: 129 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)