Skip to content

Commit

Permalink
Add ESM watch test
Browse files Browse the repository at this point in the history
  • Loading branch information
micaww committed Oct 14, 2023
1 parent 95fb3df commit a3e1b5d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ import utils = require('./lib/utils');
console.log("Loading ESCMAScript modules not available on NodeJS < 12.0.0.");
process.exit(1);
}
if (program.watch) {
console.log("Watch mode not supported for ECMAScript lambda modules.");
process.exit(1);
}
}
var event = function(){
if(program.watch) return null;
Expand Down
3 changes: 3 additions & 0 deletions test/functs/test-func-esm-echo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function handler(event, context) {
context.succeed(event);
}
21 changes: 13 additions & 8 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,6 @@ describe("- Testing cli.js", function () {
assert.equal(r.status, 1);
console.log(r.output);
});

it("should fail: esm with unsupported watch mode", function () {
var command = get_shell("node ../build/cli.js -l ./functs/test-func-esm.mjs --esm --watch");
var r = spawnSync(command[0], command[1]);
process_outputs(r);
assert.equal(r.status, 1);
console.log(r.output);
})
});

describe("* Environment test run", function () {
Expand Down Expand Up @@ -673,6 +665,19 @@ describe("- Testing cli.js", function () {
cb
);
});
it("test watch with esm", function (cb) {
var command = get_shell("node ../build/cli.js -l ./functs/test-func-esm-echo.mjs --watch --esm");
var r = spawnAsync(command[0], command[1]);
doRequestWhenReady(r,
{
"hey": "data",
},
(result) => {
assert.deepEqual(result["body"], {"hey": "data"});
},
cb
);
});
});
}

Expand Down

0 comments on commit a3e1b5d

Please sign in to comment.