File tree 3 files changed +28
-6
lines changed
3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ module.exports = {
6
6
collectCoverage : false ,
7
7
testMatch : [ '**/?(*.)+(spec|test).[tj]s?(x)' ] ,
8
8
transform : {
9
- '^.+\\.ts$' : 'ts-jest' ,
9
+ '^.+\\.ts$' : [ 'ts-jest' , {
10
+ tsconfig : 'test/tsconfig.json' ,
11
+ } ] ,
10
12
} ,
11
13
collectCoverageFrom : [
12
14
'<rootDir>/packages/*/src/**/*.[jt]s' ,
@@ -19,9 +21,4 @@ module.exports = {
19
21
'dist/package.json' ,
20
22
'<rootDir>/package.json' ,
21
23
] ,
22
- globals : {
23
- 'ts-jest' : {
24
- tsconfig : 'test/tsconfig.json' ,
25
- } ,
26
- } ,
27
24
} ;
Original file line number Diff line number Diff line change @@ -726,6 +726,20 @@ export class Actor<Data extends Dictionary = Dictionary> {
726
726
return input ;
727
727
}
728
728
729
+ /**
730
+ * Gets the actor input value just like the {@apilink Actor.getInput} method,
731
+ * but throws if it is not found.
732
+ */
733
+ async getInputOrThrow < T = Dictionary | string | Buffer > ( ) : Promise < T > {
734
+ const input = await this . getInput < T > ( ) ;
735
+
736
+ if ( input == null ) {
737
+ throw new Error ( 'Input does not exist' ) ;
738
+ }
739
+
740
+ return input ;
741
+ }
742
+
729
743
/**
730
744
* Opens a key-value store and returns a promise resolving to an instance of the {@apilink KeyValueStore} class.
731
745
*
@@ -1323,6 +1337,14 @@ export class Actor<Data extends Dictionary = Dictionary> {
1323
1337
return Actor . getDefaultInstance ( ) . getInput ( ) ;
1324
1338
}
1325
1339
1340
+ /**
1341
+ * Gets the actor input value just like the {@apilink Actor.getInput} method,
1342
+ * but throws if it is not found.
1343
+ */
1344
+ static async getInputOrThrow < T = Dictionary | string | Buffer > ( ) : Promise < T > {
1345
+ return Actor . getDefaultInstance ( ) . getInputOrThrow < T > ( ) ;
1346
+ }
1347
+
1326
1348
/**
1327
1349
* Opens a key-value store and returns a promise resolving to an instance of the {@apilink KeyValueStore} class.
1328
1350
*
Original file line number Diff line number Diff line change @@ -950,6 +950,9 @@ describe('Actor', () => {
950
950
const TestingActor = new Actor ( ) ;
951
951
952
952
test ( 'should work' , async ( ) => {
953
+ await expect ( TestingActor . getInput ( ) ) . resolves . toBeNull ( ) ;
954
+ await expect ( TestingActor . getInputOrThrow ( ) ) . rejects . toThrowError ( 'Input does not exist' ) ;
955
+
953
956
const mockGetValue = jest . spyOn ( TestingActor , 'getValue' ) ;
954
957
mockGetValue . mockImplementation ( async ( key ) => expect ( key ) . toEqual ( KEY_VALUE_STORE_KEYS . INPUT ) ) ;
955
958
You can’t perform that action at this time.
0 commit comments