Trying to get a very simple Mocha and Sinon test running for a basic Lambda function. I have two files: a.js
and b.js
. I want to test the handler
function in a.js
// a.js
const queue = require('../helpers/sqs')
module.exports.handler = async ev => {
// do stuff
}
and
// b.js
const aws = require('aws-sdk')
...
As you can see, a
requires b
and b
requires aws-sdk
. I'm trying to get something very basic working but it's complaining that aws-sdk
cannot be found. I want to test the handler function in a
without b
being called. How can I stub using Sinon so that the requirement for aws is not an issue?
const expect = require('chai').expect
const sinon = require('sinon')
const { handler } = require('../handlers/a')
describe('This', () => {
it('should work', () => {
expect(5).to.equal(5) // just something to work
})
})
Aucun commentaire:
Enregistrer un commentaire