File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ module.exports = {
66 collectCoverage : false ,
77 testMatch : [ '**/?(*.)+(spec|test).[tj]s?(x)' ] ,
88 transform : {
9- '^.+\\.ts$' : 'ts-jest' ,
9+ '^.+\\.ts$' : [ 'ts-jest' , {
10+ tsconfig : 'test/tsconfig.json' ,
11+ } ] ,
1012 } ,
1113 collectCoverageFrom : [
1214 '<rootDir>/packages/*/src/**/*.[jt]s' ,
@@ -19,9 +21,4 @@ module.exports = {
1921 'dist/package.json' ,
2022 '<rootDir>/package.json' ,
2123 ] ,
22- globals : {
23- 'ts-jest' : {
24- tsconfig : 'test/tsconfig.json' ,
25- } ,
26- } ,
2724} ;
Original file line number Diff line number Diff line change @@ -726,6 +726,20 @@ export class Actor<Data extends Dictionary = Dictionary> {
726726 return input ;
727727 }
728728
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+
729743 /**
730744 * Opens a key-value store and returns a promise resolving to an instance of the {@apilink KeyValueStore} class.
731745 *
@@ -1323,6 +1337,14 @@ export class Actor<Data extends Dictionary = Dictionary> {
13231337 return Actor . getDefaultInstance ( ) . getInput ( ) ;
13241338 }
13251339
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+
13261348 /**
13271349 * Opens a key-value store and returns a promise resolving to an instance of the {@apilink KeyValueStore} class.
13281350 *
Original file line number Diff line number Diff line change @@ -950,6 +950,9 @@ describe('Actor', () => {
950950 const TestingActor = new Actor ( ) ;
951951
952952 test ( 'should work' , async ( ) => {
953+ await expect ( TestingActor . getInput ( ) ) . resolves . toBeNull ( ) ;
954+ await expect ( TestingActor . getInputOrThrow ( ) ) . rejects . toThrowError ( 'Input does not exist' ) ;
955+
953956 const mockGetValue = jest . spyOn ( TestingActor , 'getValue' ) ;
954957 mockGetValue . mockImplementation ( async ( key ) => expect ( key ) . toEqual ( KEY_VALUE_STORE_KEYS . INPUT ) ) ;
955958
You can’t perform that action at this time.
0 commit comments