mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
refactor(tests): ensure test files have the .test.ts extension (#11801)
This commit is contained in:
parent
61f9e0d085
commit
c4f5d12f3f
@ -1,7 +1,7 @@
|
||||
{
|
||||
"all": true,
|
||||
"cache": false,
|
||||
"exclude": ["node_modules", "**/*.d.ts"],
|
||||
"exclude": ["**/*.d.ts"],
|
||||
"exclude-after-remap": true,
|
||||
"extension": [".ts"],
|
||||
"include": ["build/compiled/src/**", "src/**"],
|
||||
|
||||
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -33,8 +33,8 @@
|
||||
|
||||
- [ ] Code is up-to-date with the `master` branch
|
||||
- [ ] This pull request links relevant issues as `Fixes #00000`
|
||||
- [ ] There are new or updated unit tests validating the change
|
||||
- [ ] Documentation has been updated to reflect this change
|
||||
- [ ] There are new or updated tests validating the change (`tests/**.test.ts`)
|
||||
- [ ] Documentation has been updated to reflect this change (`docs/docs/**.md`)
|
||||
|
||||
<!--
|
||||
🎉 Thank you for contributing and making TypeORM even better!
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
{
|
||||
"__comment": "TODO: remove --exit flag: https://mochajs.org/#-exit",
|
||||
"exit": true,
|
||||
"$schema": "https://json.schemastore.org/mocharc",
|
||||
"check-leaks": true,
|
||||
"color": true,
|
||||
"exit": true,
|
||||
"file": ["./build/compiled/test/utils/test-setup.js"],
|
||||
"recursive": true,
|
||||
"spec": ["./build/compiled/test"],
|
||||
"spec": ["./build/compiled/test/**/*.test.{js,ts}"],
|
||||
"timeout": 90000
|
||||
}
|
||||
|
||||
90
DEVELOPER.md
90
DEVELOPER.md
@ -2,11 +2,11 @@
|
||||
|
||||
This document describes how to set up your development environment and run TypeORM test cases.
|
||||
|
||||
* [Prerequisite Software](#prerequisite-software)
|
||||
* [Getting the Sources](#getting-the-sources)
|
||||
* [Installing NPM Modules](#installing-npm-modules)
|
||||
* [Building](#building)
|
||||
* [Running Tests Locally](#running-tests-locally)
|
||||
- [Prerequisite Software](#prerequisite-software)
|
||||
- [Getting the Sources](#getting-the-sources)
|
||||
- [Installing NPM Modules](#installing-npm-modules)
|
||||
- [Building](#building)
|
||||
- [Running Tests Locally](#running-tests-locally)
|
||||
|
||||
See the [contribution guidelines](https://github.com/typeorm/typeorm/blob/master/CONTRIBUTING.md)
|
||||
if you'd like to contribute to TypeORM.
|
||||
@ -16,19 +16,19 @@ if you'd like to contribute to TypeORM.
|
||||
Before you can build and test TypeORM, you must install and configure the
|
||||
following products on your development machine:
|
||||
|
||||
* [Git](http://git-scm.com) and/or the **GitHub app** (for [Mac](http://mac.github.com) or
|
||||
[Windows](http://windows.github.com)); [GitHub's Guide to Installing
|
||||
Git](https://help.github.com/articles/set-up-git) is a good source of information.
|
||||
* [Node.js](http://nodejs.org), (better to install latest version) which is used to run a development web server,
|
||||
run tests, and generate distributable files.
|
||||
Depending on your system, you can install Node either from source or as a pre-packaged bundle.
|
||||
* [Mysql](https://www.mysql.com/) is required to run tests on this platform (or docker)
|
||||
* [MariaDB](https://mariadb.com/) is required to run tests on this platform (or docker)
|
||||
* [Postgres](https://www.postgresql.org/) is required to run tests on this platform (or docker)
|
||||
* [Oracle](https://www.oracle.com/database/index.html) is required to run tests on this platform
|
||||
* [Microsoft SQL Server](https://www.microsoft.com/en-us/cloud-platform/sql-server) is required to run tests on this platform
|
||||
* For MySQL, MariaDB and Postgres you can use [docker](https://www.docker.com/) instead (docker configuration is
|
||||
[here](https://github.com/typeorm/typeorm/blob/master/docker-compose.yml))
|
||||
- [Git](http://git-scm.com) and/or the **GitHub app** (for [Mac](http://mac.github.com) or
|
||||
[Windows](http://windows.github.com)); [GitHub's Guide to Installing
|
||||
Git](https://help.github.com/articles/set-up-git) is a good source of information.
|
||||
- [Node.js](http://nodejs.org), (better to install latest version) which is used to run a development web server,
|
||||
run tests, and generate distributable files.
|
||||
Depending on your system, you can install Node either from source or as a pre-packaged bundle.
|
||||
- [Mysql](https://www.mysql.com/) is required to run tests on this platform (or docker)
|
||||
- [MariaDB](https://mariadb.com/) is required to run tests on this platform (or docker)
|
||||
- [Postgres](https://www.postgresql.org/) is required to run tests on this platform (or docker)
|
||||
- [Oracle](https://www.oracle.com/database/index.html) is required to run tests on this platform
|
||||
- [Microsoft SQL Server](https://www.microsoft.com/en-us/cloud-platform/sql-server) is required to run tests on this platform
|
||||
- For MySQL, MariaDB and Postgres you can use [docker](https://www.docker.com/) instead (docker configuration is
|
||||
[here](https://github.com/typeorm/typeorm/blob/master/docker-compose.yml))
|
||||
|
||||
## Getting the Sources
|
||||
|
||||
@ -56,9 +56,9 @@ You should have node installed in the version described in [.nvmrc](.nvmrc).
|
||||
|
||||
It is recommended to configure your OS to automatically switch to use this version whenever you enter project folder. This can be achieved in many ways:
|
||||
|
||||
* [`fnm`](https://github.com/Schniz/fnm)
|
||||
* [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm#auto-use)
|
||||
* [`asdf`](https://asdf-vm.com) with `asdf-nodejs` plugin and [`legacy_version_file = true`](https://asdf-vm.com/manage/configuration.html#legacy-version-file) option
|
||||
- [`fnm`](https://github.com/Schniz/fnm)
|
||||
- [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm#auto-use)
|
||||
- [`asdf`](https://asdf-vm.com) with `asdf-nodejs` plugin and [`legacy_version_file = true`](https://asdf-vm.com/manage/configuration.html#legacy-version-file) option
|
||||
|
||||
## Installing package dependencies
|
||||
|
||||
@ -101,36 +101,46 @@ You can copy this tar into your project and run `npm install ./typeorm-x.x.x.tgz
|
||||
|
||||
It is greatly appreciated if PRs that change code come with appropriate tests.
|
||||
|
||||
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.
|
||||
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.ts` file or modify an existing one.
|
||||
|
||||
If the test is for a specific regression or issue opened on GitHub, add a comment to the tests mentioning the issue number.
|
||||
|
||||
Most tests will benefit from using this template as a starting point:
|
||||
|
||||
```ts
|
||||
import "reflect-metadata";
|
||||
import { createTestingConnections, closeTestingConnections, reloadTestingDatabases } from "../../utils/test-utils";
|
||||
import { expect } from "chai"
|
||||
import "reflect-metadata"
|
||||
import {
|
||||
closeTestingConnections,
|
||||
createTestingConnections,
|
||||
reloadTestingDatabases,
|
||||
} from "../../utils/test-utils"
|
||||
import { DataSource } from "../../../src/data-source/DataSource"
|
||||
import { expect } from "chai";
|
||||
|
||||
describe("description of the functionality you're testing", () => {
|
||||
let dataSources: DataSource[]
|
||||
|
||||
let dataSources: DataSource[];
|
||||
before(async () => dataSources = await createTestingConnections({
|
||||
entities: [__dirname + "/entity/*{.js,.ts}"],
|
||||
schemaCreate: true,
|
||||
dropSchema: true,
|
||||
}));
|
||||
beforeEach(() => reloadTestingDatabases(dataSources));
|
||||
after(() => closeTestingConnections(dataSources));
|
||||
before(
|
||||
async () =>
|
||||
(dataSources = await createTestingConnections({
|
||||
entities: [__dirname + "/entity/*{.js,.ts}"],
|
||||
schemaCreate: true,
|
||||
dropSchema: true,
|
||||
})),
|
||||
)
|
||||
beforeEach(() => reloadTestingDatabases(dataSources))
|
||||
after(() => closeTestingConnections(dataSources))
|
||||
|
||||
// optional: test fix for issue https://github.com/typeorm/typeorm/issues/<issue-number>
|
||||
it("should <put a detailed description of what it should do here>", () => Promise.all(dataSources.map(async dataSource => {
|
||||
// tests go here
|
||||
})));
|
||||
it("should <put a detailed description of what it should do here>", () =>
|
||||
Promise.all(
|
||||
dataSources.map(async (dataSource) => {
|
||||
// tests go here
|
||||
}),
|
||||
))
|
||||
|
||||
// you can add additional tests if needed
|
||||
});
|
||||
// you can add additional tests if needed
|
||||
})
|
||||
```
|
||||
|
||||
If you place entities in `./entity/<entity-name>.ts` relative to your test file,
|
||||
@ -173,8 +183,8 @@ Once TypeScript finishes compiling your changes, you can run `npm run test:fast`
|
||||
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
|
||||
- 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
|
||||
|
||||
## Release Process
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ describe("benchmark > bulk-sql-build", () => {
|
||||
before(async () => {
|
||||
dataSources = await createTestingConnections({
|
||||
__dirname,
|
||||
enabledDrivers: ["postgres"],
|
||||
})
|
||||
})
|
||||
beforeEach(() => reloadTestingDatabases(dataSources))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user