So I've been tasked with testing an express app that contains an AWS Lambda. I'm trying to test two methods in a file that look like this.
Validator.js
const Verifier = require('@companyName/api-jwt-validation');
JWTAPIFunc = function(callType){
return function (req,res,next){
.
.
.
try {
.
.
.
} catch (authorizationError) {
.
.
.
}
}
}
module.exports = {
JWTAPIFunc:JWTAPIFunc
};
I want to test this JWTAPIFunc using jest so I have a test file that looks like this
Validator.test.js
const Verifier = require('@companyName/api-jwt-validation');
const Validator = require('../Validator')
jest.mock(Verifier);
test('Do something', ()=>{
});
When I run this empty test I get this error
● Test suite failed to run
ReferenceError: JWTAPIFunc is not defined
1 | const Verifier = require('@companyName/api-jwt-validation');
2 |
> 3 | JWTAPIFunc = function(callType){
| ^
4 | return function (req,res,next){
at Object.<anonymous> (src/Validator.js:3:17)
at Object.<anonymous> (src/__tests__/Validator.test.js:3:1)
Why is it saying that this function is not defined? Sorry again if this is a stupid question.
Aucun commentaire:
Enregistrer un commentaire