File tree 3 files changed +25
-3
lines changed
3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 1
1
module . exports = {
2
+ 'runner' : 'groups' ,
2
3
'preset' : 'ts-jest' ,
3
4
'transform' : {
4
5
'^.+\\.ts?$' : 'ts-jest' ,
Original file line number Diff line number Diff line change @@ -16,6 +16,19 @@ interface LooseObject {
16
16
[ key : string ] : string
17
17
}
18
18
19
+ type DummyEvent = {
20
+ key1 : string
21
+ key2 : string
22
+ key3 : string
23
+ } ;
24
+
25
+ /**
26
+ * Metrics tests
27
+ *
28
+ * @group metrics
29
+ * @group unit/Metrics
30
+ */
31
+
19
32
describe ( 'Class: Metrics' , ( ) => {
20
33
const originalEnvironmentVariables = process . env ;
21
34
@@ -229,7 +242,7 @@ describe('Class: Metrics', () => {
229
242
test ( 'Cold start metric should only be written out once and flushed automatically' , async ( ) => {
230
243
const metrics = new Metrics ( { namespace : 'test' } ) ;
231
244
232
- const handler = async ( _event : unknown , _context : unknown ) : Promise < void > => {
245
+ const handler = async ( _event : DummyEvent , _context : Context ) : Promise < void > => {
233
246
// Should generate only one log
234
247
metrics . captureColdStartMetric ( ) ;
235
248
} ;
@@ -363,7 +376,7 @@ describe('Class: Metrics', () => {
363
376
expect . assertions ( 1 ) ;
364
377
365
378
const metrics = new Metrics ( { namespace : 'test' } ) ;
366
- const handler = async ( _event : unknown , _context : unknown ) : Promise < void > => {
379
+ const handler = async ( _event : DummyEvent , _context : Context ) : Promise < void > => {
367
380
metrics . raiseOnEmptyMetrics ( ) ;
368
381
// Logic goes here
369
382
metrics . purgeStoredMetrics ( ) ;
Original file line number Diff line number Diff line change 1
1
import { logMetrics } from '../../../../metrics/src/middleware' ;
2
2
import { Metrics , MetricUnits } from '../../../../metrics/src' ;
3
3
import middy from '@middy/core' ;
4
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
+ // @ts -ignore
6
+ import * as event from '../../../../../tests/resources/events/custom/hello-world.json' ;
4
7
import { ExtraOptions } from '../../../src/types' ;
5
8
6
9
const consoleSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
7
10
const mockDate = new Date ( 1466424490000 ) ;
8
11
const dateSpy = jest . spyOn ( global , 'Date' ) . mockImplementation ( ( ) => mockDate as unknown as string ) ;
9
12
13
+ /**
14
+ * Metrics tests
15
+ *
16
+ * @group metrics
17
+ * @group unit/middleware
18
+ */
10
19
describe ( 'Middy middleware' , ( ) => {
11
20
12
21
beforeEach ( ( ) => {
@@ -17,7 +26,6 @@ describe('Middy middleware', () => {
17
26
18
27
describe ( 'logMetrics' , ( ) => {
19
28
20
- const event = { foo : 'bar' } ;
21
29
const getRandomInt = ( ) : number => Math . floor ( Math . random ( ) * 1000000000 ) ;
22
30
const awsRequestId = getRandomInt ( ) . toString ( ) ;
23
31
You can’t perform that action at this time.
0 commit comments