Skip to content

Commit 3ffeea5

Browse files
authored
docs: clarify where to add tests (#11438)
1 parent 274bdf2 commit 3ffeea5

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

DEVELOPER.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ You can copy this tar into your project and run `npm install ./typeorm-x.x.x.tgz
8989

9090
## Running Tests Locally
9191

92-
It would be greatly appreciated if PRs that change code come with appropriate tests.
92+
It is greatly appreciated if PRs that change code come with appropriate tests.
9393

94-
To create a test for a specific issue opened on GitHub, create a file: `test/github-issues/<num>/issue-<num>.ts` where
95-
`<num>` is the corresponding GitHub issue. For example, if you were creating a PR to fix github issue #363, you'd
96-
create `test/github-issues/363/issue-363.ts`.
94+
To create a new test, check the [relevant functional tests](https://github.com/typeorm/typeorm/tree/master/test/functional). Depending on the test, you may need to create a new test file or modify an existing one.
95+
96+
If the test is for a specific regression or issue opened on GitHub, add a comment to the tests mentioning the issue number.
9797

9898
Most tests will benefit from using this template as a starting point:
9999

@@ -103,7 +103,7 @@ import { createTestingConnections, closeTestingConnections, reloadTestingDatabas
103103
import { DataSource } from "../../../src/data-source/DataSource"
104104
import { expect } from "chai";
105105

106-
describe("github issues > #<issue number> <issue title>", () => {
106+
describe("description of the functionality you're testing", () => {
107107

108108
let dataSources: DataSource[];
109109
before(async () => dataSources = await createTestingConnections({
@@ -114,18 +114,16 @@ describe("github issues > #<issue number> <issue title>", () => {
114114
beforeEach(() => reloadTestingDatabases(dataSources));
115115
after(() => closeTestingConnections(dataSources));
116116

117+
// optional: test fix for issue https://github.com/typeorm/typeorm/issues/<issue-number>
117118
it("should <put a detailed description of what it should do here>", () => Promise.all(dataSources.map(async dataSource => {
118-
119119
// tests go here
120-
121120
})));
122121

123-
// you can add additional tests if needed
124-
122+
// you can add additional tests if needed
125123
});
126124
```
127125

128-
If you place entities in `./entity/<entity-name>.ts` relative to your `issue-<num>.ts` file,
126+
If you place entities in `./entity/<entity-name>.ts` relative to your test file,
129127
they will automatically be loaded.
130128

131129
To run the tests, setup your environment configuration by copying `ormconfig.sample.json` into `ormconfig.json` and replacing parameters with your own. The tests will be run for each database that is defined in that file. If you're working on something that's not database specific and you want to speed things up, you can pick which objects in the file make sense for you to keep.
@@ -149,7 +147,7 @@ describe.only('your describe test', ....)
149147
Alternatively, you can use the `--grep` flag to pass a regex to `mocha`. Only the tests that have `describe`/`it` statements that match the regex will be run. For example:
150148

151149
```shell
152-
npm run test -- --grep "github issues > #363"
150+
npm run test -- --grep "your test name"
153151
```
154152

155153
### Faster developer cycle for editing code and running tests

0 commit comments

Comments
 (0)