我看到以下使用
mocha
和
chai
库作为测试用例。
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
这是
code
用于测试亚马逊 lambda 函数的处理程序。(目前,我没有使用
super-test
npm 模块)
const expect = require('chai').expect;
const mongoose = require('mongoose');
const CONFIG_DEV_MONGODB = require('../../config/config.dev').DB_CONNECTION_URL;
describe('get the foo', () => {
let handler;
before(() => {
process.env.DEPLOYMENT_STAGE = 'test';
process.env.DB_CONNECTION_URL = CONFIG_DEV_MONGODB;
handler = require('./get');
after(() => {
if (mongoose.connection) {
mongoose.connection.close();
it('validate getFeaturedProducts get request with storeid',function(done){
//request has the sample data for event
let request = require('../../test/fixtures/featureProductJSON');
handler.getFeaturedProducts(request, {} , (error, result) => {
expect(error).to.be.null;
expect(result).to.be.not.null;
done()
这是处理程序
module.exports.getFeaturedProducts = function (event, context, callback) {
..............
.......
mongoConnection.then( function() {
return callback(null, 'test');
}, function (error) {
return return callback(true, null);;
谁能解释一下发生了什么
原文由 made_in_india 发布,翻译遵循 CC BY-SA 4.0 许可协议