Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: tidied existing mocha test scripts in package.json and added a test-ts script #10864

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .mocharc-compiled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Mocha configuration file for `npm test` / `npm run test` and `npm run test-fast`; includes the file spec.
bail: true
exit: true
recursive: true
require:
- 'build/compiled/test/utils/test-setup.js'
spec:
- 'build/compiled/test'
timeout: '90000'
14 changes: 14 additions & 0 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Mocha configuration file for testing individual tests with `npm run test-ts path/to/test.ts` or `npx mocha path/to/test.ts`.
# This configuration does not include the file spec, and eliminates the need for running `tsc` beforehand, by using `ts-node`.
bail: true
exit: true
extension:
- js
- ts
recursive: true
require:
- 'ts-node/register'
- 'test/utils/test-setup.ts'

# High timeout (in milliseconds) to allow for debugging tests in a debugger.
timeout: '600000'
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@
"yargs": "^17.6.2"
},
"scripts": {
"test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 90000 ./build/compiled/test",
"test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 90000 ./build/compiled/test",
"test": "rimraf ./build && tsc && mocha --config=.mocharc-compiled.yaml",
"test-fast": "mocha --config=.mocharc-compiled.yaml",
"test-ts": "mocha",
"compile": "rimraf ./build && tsc",
"watch": "./node_modules/.bin/tsc -w",
"package": "gulp package",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { postgres } from "./generate/postgres"
import { sqlite } from "./generate/sqlite"
import { oracle } from "./generate/oracle"
import { cockroachdb } from "./generate/cockroachdb"
import { mssql } from "./generate/mssql.js"
import { mssql } from "./generate/mssql"

export const resultsTemplates: Record<string, any> = {
mysql,
Expand Down
2 changes: 1 addition & 1 deletion test/github-issues/4219/shim.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let _Shim: any
try {
// We're in /test
_Shim = require("../../../../extra/typeorm-class-transformer-shim")
_Shim = require("../../../extra/typeorm-class-transformer-shim")
} catch (e) {
// We're in /build/compiled/test
_Shim = require("../../../../../extra/typeorm-class-transformer-shim")
Expand Down
2 changes: 1 addition & 1 deletion test/github-issues/9984/issue-9984.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
createTestingConnections,
reloadTestingDatabases,
} from "../../utils/test-utils"
import { Post } from "./entity/Post.js"
import { Post } from "./entity/Post"
import { expect } from "chai"

describe("github issues > #9984 TransactionRetryWithProtoRefreshError should be handled by TypeORM", () => {
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
"node_modules",
"temp",
"tmp"
]
],
"ts-node": {
"transpileOnly": true,
}
}