You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// load the module under test and configure it for the
52
-
// robot. This is in place of external-scripts
53
-
require("../index")(robot);
54
-
55
-
robot.adapter.on("connected", () => {
56
-
// create a user
57
-
user =robot.brain.userForId("1", {
58
-
name:"mocha",
59
-
room:"#mocha",
60
-
});
61
-
adapter =robot.adapter;
62
-
done();
63
-
});
64
-
65
-
// start the bot
66
-
robot.run();
67
-
});
68
-
});
69
-
70
-
afterEach(function () {
71
-
robot.shutdown();
72
-
});
26
+
Create a test file in a folder. e.g. [index.test.mjs](test/index.test.mjs).
73
27
74
-
it("responds when greeted", function (done) {
75
-
// here's where the magic happens!
76
-
adapter.on("reply", function (envelope, strings) {
77
-
expect(strings[0]).match(/Why hello there/);
28
+
You'll need a Node version > 17.
78
29
79
-
done();
80
-
});
30
+
Assuming your tests are in `test/` or have `.test.` before the file extension, just run `node --test`. For less typing, in your `package.json`, add a `test` script:
0 commit comments