docs: Improve DEVELOPER.md documentation (#11289)

This commit is contained in:
Alper Cugun 2025-02-14 21:14:02 +01:00 committed by GitHub
parent 1cd3ff729d
commit e3056d15ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,7 +73,7 @@ To build a distribution package of TypeORM run:
npm run package
```
This command will generate you a distribution package in the `build/package` directory.
This command will generate a distribution package in the `build/package` directory.
You can link (or simply copy/paste) this directory into your project and test TypeORM there
(but make sure to keep all node_modules required by TypeORM).
@ -83,15 +83,15 @@ To build the distribution package of TypeORM packed into a `.tgz`, run:
npm run pack
```
This command will generate you a distribution package tar in the `build` directory (`build/typeorm-x.x.x.tgz`).
This command will generate a distribution package tar in the `build` directory (`build/typeorm-x.x.x.tgz`).
You can copy this tar into your project and run `npm install ./typeorm-x.x.x.tgz` to bundle your build of TypeORM in your project.
## Running Tests Locally
It would be greatly appreciated if PRs that change code come with appropriate tests.
To create a test for a specific issue opened on github, create a file: `test/github-issues/<num>/issue-<num>.ts` where
`<num>` is the corresponding github issue. For example, if you were creating a PR to fix github issue #363, you'd
To create a test for a specific issue opened on GitHub, create a file: `test/github-issues/<num>/issue-<num>.ts` where
`<num>` is the corresponding GitHub issue. For example, if you were creating a PR to fix github issue #363, you'd
create `test/github-issues/363/issue-363.ts`.
Most tests will benefit from using this template as a starting point:
@ -127,32 +127,29 @@ describe("github issues > #<issue number> <issue title>", () => {
If you place entities in `./entity/<entity-name>.ts` relative to your `issue-<num>.ts` file,
they will automatically be loaded.
To run the tests, setup your environment configuration by copying `ormconfig.json.dist` into `ormconfig.json` and
replacing parameters with your own.
To run the tests, setup your environment configuration by copying `ormconfig.json.dist` 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.
Then run tests:
Run the tests as follows:
```shell
npm test
```
You should execute test suites before submitting a PR to github.
All the tests are executed on our Continuous Integration infrastructure and a PR could only be merged once the tests pass.
You should make sure the test suites pass before submitting a PR to GitHub. Tests are run on PRs via GitHub Actions after approval, but your fork repository should be able to run CI as well. All tests need to pass before a PR will be merged.
**Executing only some tests**: When you are creating tests to some specific code, you may want only execute the tests that you're creating, so you waste less time to verify your code. To do this, you can temporarily modify your tests definitions adding `.only` *mocha* commands **(describe, it)**. Example:
**Executing only some tests**: When you are creating tests to some specific code, you may want to only execute the tests that you're creating.
To do this, you can temporarily modify your test definitions by adding [`.only` *mocha* commands](https://mochajs.org/#exclusive-tests) to `describe` and `it`. For example:
```
describe.only('your describe test', ....)
```
>**Hint:** you can use the `--grep` flag to pass a Regex to `gulp-mocha`. Only the tests have have `describe`/`it`
>statements that match the Regex will be run. For example:
>
>```shell
>npm test -- --grep="github issues > #363"
>```
>
>This is useful when trying to get a specific test or subset of tests to pass.
Alternatively, you can use the `--grep` flag to pass a regex to `gulp-mocha`. Only the tests that have `describe`/`it` statements that match the regex will be run. For example:
```shell
npm test -- --grep="github issues > #363"
```
### Faster developer cycle for editing code and running tests
@ -164,9 +161,8 @@ Once TypeScript finishes compiling your changes, you can run `npm run test-fast`
## Using Docker
To run your tests you need dbms installed on your machine. Alternatively, you can use docker
with all dbms images inside it. To use dbms for your tests from docker simply run `docker-compose up`
in the root of the project. Once all images are fetched and run you can run tests.
To run your tests you need the Database Management Systems (DBMS) installed on your machine. Alternatively, you can use docker with the DBMS running in containers. To have docker run all the DBMS for you simply run `docker-compose up`
in the root of the project. Once all images are fetched and are running, you can run the tests.
- The docker image of mssql-server needs at least 3.25GB of RAM.
- Make sure to assign enough memory to the Docker VM if you're running on Docker for Mac or Windows