-
-
Notifications
You must be signed in to change notification settings - Fork 687
Open
Labels
Description
Is your feature request related to a problem? Please describe.
We have typescript_test and tsx_test (and so on) targets, but the test goal doesn't find them.
Describe the solution you'd like
Running pants test :: should run typescript tests, somehow.
Notes:
- these may interact with javascript tests
- tools like
@babel/preset-typescript(https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#typescript-support) and https://www.npmjs.com/package/ts-jest allow.tsfiles to be fed into jest directly, i.e.npx jestwill run.tstests.
Demo using ts-jest:
cd $(mktemp -d)
cat > package.json <<'EOF'
{
"name": "demo",
"version": "0.0.1",
"scripts": {
"test": "npx jest"
},
"dependencies": {
"@types/jest": "29.5.14",
"jest": "29.7.0",
"ts-jest": "29.3.0"
},
"jest": {
"testMatch": ["<rootDir>/**/*.test.{js,ts}"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
}
}
}
EOF
cat > typescript.test.ts <<EOF
test("typescript", () => {});
EOF
# setup the lockfile
npm install
# OKAY: running tests outside of pants runs TS tests
npm test
# PASS ./typescript.test.ts
# Now try Pants:
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.26.0a0"
backend_packages.add = [
"pants.backend.experimental.javascript",
"pants.backend.experimental.typescript",
]
[nodejs]
package_manager = "npm"
EOF
cat > BUILD <<EOF
package_json(name="root", dependencies=[], scripts=[node_test_script()])
typescript_tests(name="ts_tests")
EOF
# Currently runs nothing:
pants test ::Describe alternatives you've considered
None yet.
Additional context
tomascsantos and lucacavallaro