Skip to content

Commit cd446c1

Browse files
committed
CCM-11192: Test data script
1 parent 25ebd21 commit cd446c1

File tree

14 files changed

+4477
-1
lines changed

14 files changed

+4477
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"workspaces": [
7272
"lambdas/api-handler",
7373
"lambdas/authorizer",
74-
"internal/datastore"
74+
"internal/datastore",
75+
"scripts/test-data"
7576
]
7677
}

scripts/test-data/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

scripts/test-data/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage
2+
node_modules
3+
dist
4+
.reports

scripts/test-data/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Test letter generator
2+
3+
Simple script to generate test data. It uploads a PDF to the test S3 bucket and inserts a new record in the database.
4+
5+
## Usage
6+
7+
Log in the desired AWS account and then run the command below. Note that the AWS account ID is required in order to resolve the bucket name.
8+
9+
```bash
10+
npm run cli -- create-letter \
11+
--supplier-id supplier-id \
12+
--environment pr147 \
13+
--awsAccountId 820178564574 \
14+
--letter-id letter-id \
15+
--group-id group-id \
16+
--specification-id specification-id \
17+
--status PENDING
18+
```

scripts/test-data/jest.config.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import type { Config } from 'jest';
2+
3+
export const baseJestConfig: Config = {
4+
preset: 'ts-jest',
5+
6+
// Automatically clear mock calls, instances, contexts and results before every test
7+
clearMocks: true,
8+
9+
// Indicates whether the coverage information should be collected while executing the test
10+
collectCoverage: true,
11+
12+
// The directory where Jest should output its coverage files
13+
coverageDirectory: './.reports/unit/coverage',
14+
15+
// Indicates which provider should be used to instrument code for coverage
16+
coverageProvider: 'babel',
17+
18+
coverageThreshold: {
19+
global: {
20+
branches: 100,
21+
functions: 100,
22+
lines: 100,
23+
statements: -10,
24+
},
25+
},
26+
27+
coveragePathIgnorePatterns: ['/__tests__/'],
28+
transform: { '^.+\\.ts$': 'ts-jest' },
29+
testPathIgnorePatterns: ['.build'],
30+
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
31+
32+
// Use this configuration option to add custom reporters to Jest
33+
reporters: [
34+
'default',
35+
[
36+
'jest-html-reporter',
37+
{
38+
pageTitle: 'Test Report',
39+
outputPath: './.reports/unit/test-report.html',
40+
includeFailureMsg: true,
41+
},
42+
],
43+
],
44+
45+
// The test environment that will be used for testing
46+
testEnvironment: 'jsdom',
47+
};
48+
49+
const utilsJestConfig = {
50+
...baseJestConfig,
51+
52+
testEnvironment: 'node',
53+
54+
coveragePathIgnorePatterns: [
55+
...(baseJestConfig.coveragePathIgnorePatterns ?? []),
56+
'cli/index.ts',
57+
'helpers/s3_helpers.ts',
58+
'letter-repo-factory.ts',
59+
],
60+
};
61+
62+
export default utilsJestConfig;

0 commit comments

Comments
 (0)