Skip to content

Commit f90ba87

Browse files
committed
homogenize tests run process
1 parent 0de1d03 commit f90ba87

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

Diff for: CONTRIBUTING.md

+13-14
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ You can run each group separately or all together thanks to [jest-runner-groups]
6565

6666
Unit tests, under `tests/unit` folder are standard [Jest](https://jestjs.io) tests.
6767

68-
End-to-end tests, under `tests/e2e` folder, will test the module features by deploying AWS Lambda functions into your AWS Account. We use CDK lib for Typescript for creating infrastructure, and `aws sdk` for invoking the functions and assert on the expected behaviors. All steps are also executed by Jest.
68+
End-to-end tests, under `tests/e2e` folder, will test the module features by deploying AWS Lambda functions into your AWS Account. We use [aws-cdk](https://docs.aws.amazon.com/cdk/v1/guide/getting_started.html) v1 library (not v2 due to [this cdk issue](https://github.com/aws/aws-cdk/issues/18211)) for Typescript for creating infrastructure, and [aws-sdk-js v2](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/) for invoking the functions and assert on the expected behaviors. All steps are also executed by Jest.
69+
6970

7071
Running end-to-end tests will deploy AWS resources. You will need an AWS account and the tests might incur costs. The cost from **some services** are covered by the [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all) but not all of them. If you don't have an AWS Account follow [these instructions to create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
7172

@@ -88,11 +89,10 @@ As mentioned before, tests are split into groups thanks to [jest-runner-groups](
8889

8990
**Run**
9091

91-
Run the following command in your terminal, in the folder of a utility package (for example: `packages/metrics`):
92-
93-
`npm run test`
94-
95-
You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=unit/metrics/all`.
92+
To run unit tests you can either use
93+
* npm task `lerna-test:unit` (`npm run lerna-test:unit`) in root folder to run them all
94+
* npm task `test:e2e` (`npm run test:unit`) in module folder to run the module specific one
95+
* jest directly `npx jest --group=unit` in module folder to run the module specific one (You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=unit/metrics/class`)
9696

9797
**e2e tests**
9898

@@ -108,22 +108,21 @@ As mentioned in the previous section, tests are split into groups thanks to [jes
108108
*/
109109
```
110110

111-
and leverage [aws-cdk](https://docs.aws.amazon.com/cdk/v1/guide/getting_started.html) V1 package (not v2 due to [this cdk issue](https://github.com/aws/aws-cdk/issues/18211)) to programatically deploy and destroy stacks. See `metrics/tests/e2e/decorator.test.ts` as an example.
111+
See `metrics/tests/e2e/decorator.test.ts` as an example.
112112

113113

114114
**Run**
115115

116-
To run unit tests you can either use projen task
117-
* `npm run test:e2e` which will only run jest integ tests
118-
* or jest directly `npx jest --group=e2e`
119-
120-
You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=e2e/other/example`.
116+
To run e2e tests you can either use
117+
* npm task `lerna-test:e2e` (`npm run lerna-test:e2e`) in root folder
118+
* npm task `test:e2e` (`npm run test:e2e`) in module folder
119+
* jest directly `npx jest --group=e2e` in module folder. (You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=e2e/metrics/decorator`)
121120

122121
Two important env variable can be used:
123-
* `AWS_PROFILE` to use the right credentials
122+
* `AWS_PROFILE` to use the right AWS credentials
124123
* `DISABLE_TEARDOWN` if you don't want your stack to be destroyed at the end of the test (useful in dev mode when iterating over your code).
125124

126-
Example: `DISABLE_TEARDOWN=true AWS_PROFILE=ara npx jest --group=integ/other/example`
125+
Example: `DISABLE_TEARDOWN=true AWS_PROFILE=dev-account npx jest --group=e2e/metrics/decorator`
127126

128127
**Automate**
129128

Diff for: packages/commons/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"scripts": {
1313
"commit": "commit",
14-
"test": "jest --detectOpenHandles --coverage --verbose",
14+
"test": "npm run test:unit",
15+
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
1516
"test:e2e": "echo 'Not Applicable'",
1617
"watch": "jest --watch",
1718
"build": "tsc",

Diff for: packages/logger/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"scripts": {
1313
"commit": "commit",
14-
"test": "jest --group=unit --detectOpenHandles --coverage --verbose",
14+
"test": "npm run test:unit",
15+
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
1516
"test:e2e": "jest --group=e2e",
1617
"watch": "jest --watch",
1718
"build": "tsc",

Diff for: packages/metrics/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"scripts": {
1313
"commit": "commit",
14-
"test": "jest --group=unit --detectOpenHandles --coverage --verbose",
14+
"test": "npm run test:unit",
15+
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
1516
"test:e2e": "jest --group=e2e",
1617
"watch": "jest --group=unit --watch ",
1718
"build": "tsc",

Diff for: packages/tracing/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"scripts": {
1313
"commit": "commit",
14-
"test": "jest --group=unit --detectOpenHandles --coverage --verbose",
14+
"test": "npm run test:unit",
15+
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
1516
"test:e2e": "jest --group=e2e",
1617
"watch": "jest --watch",
1718
"build": "tsc",

0 commit comments

Comments
 (0)