mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-02 03:37:54 +02:00
Merge pull request #949 from grasdk/feature/localtest
Feature/localtest
This commit is contained in:
commit
c5c7df0a8a
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,3 +42,4 @@ test.*
|
|||||||
/coverage/
|
/coverage/
|
||||||
.nyc_output/
|
.nyc_output/
|
||||||
.vscode*
|
.vscode*
|
||||||
|
!test/setup-local.js # Excludes setup.js from the ignore rule
|
5
.mocharc.js
Normal file
5
.mocharc.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
timeout: 20000, // Set timeout to 20 seconds (good for slow test setups)
|
||||||
|
require: 'test/setup-local.js',
|
||||||
|
recursive: true, // Run tests in subdirectories
|
||||||
|
};
|
@ -105,3 +105,34 @@ Client side:
|
|||||||
15. Setting `content` BehaviorSubject (rxjs) with the `ContentWrapperWithError` from the server.
|
15. Setting `content` BehaviorSubject (rxjs) with the `ContentWrapperWithError` from the server.
|
||||||
16. Rendering gallery: UI is data binded to the `galleryService.content` [gallery.component.html]
|
16. Rendering gallery: UI is data binded to the `galleryService.content` [gallery.component.html]
|
||||||
|
|
||||||
|
## Running the tests locally
|
||||||
|
You can run tests in various ways. If you use VS Code, the built-in test explorer is a good way to visualize and run the tests. You can also run tests from the command line.
|
||||||
|
|
||||||
|
- Run all tests:
|
||||||
|
|
||||||
|
`npx mocha`
|
||||||
|
- Run all tests in parallel and report with very verbose output (to debug tests that don't run):
|
||||||
|
|
||||||
|
`npx mocha --reporter spec --parallel`
|
||||||
|
- Run a specific test (here the SettingsRouter in the backend):
|
||||||
|
|
||||||
|
`npx mocha ./test/backend/integration/routers/admin/SettingsRouter.js`
|
||||||
|
|
||||||
|
### MySQL / MariaDB tests
|
||||||
|
The MySQL / MariaDB tests needs a separate database to be running during the test. If you have docker, you can start one with the required test-settings, using the command below:
|
||||||
|
|
||||||
|
`docker run --name pigallery_test -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=pigallery_test -e MYSQL_USER=user -e MYSQL_PASSWORD=password -p3306:3306 -d mariadb:10.3 --log-bin --binlog-format=MIXED`
|
||||||
|
|
||||||
|
Start this betfore running the tests in text explorer or the command line, if you want to include the MySQL tests.
|
||||||
|
|
||||||
|
Once you're finished with the testing, you can shut down the container again:
|
||||||
|
|
||||||
|
`docker stop pigallery_test`
|
||||||
|
|
||||||
|
or you can shut it down AND remove it:
|
||||||
|
|
||||||
|
`docker stop pigallery_test && docker rm pigallery_test`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
6
test/setup-local.js
Normal file
6
test/setup-local.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
process.env.MYSQL_HOST = 'localhost';
|
||||||
|
process.env.MYSQL_USERNAME = 'root';
|
||||||
|
process.env.MYSQL_PASSWORD = 'password';
|
||||||
|
process.env.MYSQL_PORT = '3306';
|
||||||
|
process.env.PORT = '35000';
|
||||||
|
process.env.CI = 'true';
|
Loading…
Reference in New Issue
Block a user