1

Frisby.js テストを AWS Lambda にデプロイしようとしていますが、継続的に参照エラーが発生します。Lambda からの出力ログ、問題のコード、package.json の依存関係を含めました。Lambda にデプロイするときに、以前にこのような問題に遭遇した人はいますか?

Lambda 出力ログ:

module initialization error: ReferenceError: jasmine is not defined
at Object.<anonymous> (/var/task/testing/node_modules/frisby/lib/frisby.js:1125:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/testing/index.js:1:76)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

テスト ファイル:

// This test checks to see if a blog post was made the previous day

exports.handler = function index(event, context, callback){

var frisby = require("frisby");
var jasmine = require("jasmine");

var currentDate = new Date();
var yesterdayDate = new Date(currentDate.getTime() - 86400000).toISOString().split("T")[0];

// We will need to check yesterday's date against the latest blog post date, so this offset accounts for that.
var dateOffset = new Date(currentDate.getTime() - 86400000);
var offsetDayOfWeek = dateOffset.getDay();

frisby.create("will login successfully and return a JWT for future use")
    .post("http://testurl.com/login",
        { email: "email@gmail.com", password: "reallysecurepassword"},
        { json: true })
    .expectStatus(200)
    .expectHeader("Content-Type",
        "application/json; charset=utf-8")
    .afterJSON(function (res) {
        frisby.globalSetup({
            request: {
                headers: { "x-access-token": res.jwt,
                    "Content-Type": "application/json; charset=utf-8" }
            }
        });

        // Test doesn't need to run on weekends
        if(offsetDayOfWeek != 0 && offsetDayOfWeek != 6) {
            frisby.create(site + ": Gets date from most recent blog post and checks against yesterday's date")
                .get("http://testurl.com/get-blog-post")
                .expectStatus(200)
                .afterJSON(function (res) {
                    var postedDate = res[0].DatePosted.split("T")[0];
                    if (postedDate != yesterdayDate) {
                        console.log(site + ": No new blogs posted.");
                        console.log("Last blog post date: " + postedDate);
                    }
                    expect(postedDate == yesterdayDate).toBe(true);
                })
                .toss();
        }
    })
    .toss();
};

package.json の依存関係:

"dependencies": {
"body-parser": "~1.15.1",
"cookie-parser": "~1.4.3",
"debug": "~2.2.0",
"express": "~4.13.4",
"jade": "~1.11.0",
"morgan": "~1.7.0",
"serve-favicon": "~2.3.0",
"frisby": "0.8.5",
"jasmine-node": "1.14.5",
"jasmine": "2.5.1"
4

1 に答える 1