Skip to content

Commit c5869c0

Browse files
committed
Add simple integration tests to most examples
1 parent daaa81a commit c5869c0

12 files changed

+154
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ node_modules
88
dist
99
importmap.js
1010
.DS_Store
11+
test-results

package-lock.json

Lines changed: 66 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/roslib-examples/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
}
2828
],
2929
"scripts": {
30-
"start": "http-server .. -o /roslib-examples/src/index.html"
30+
"start": "http-server .. -o /roslib-examples/src/index.html",
31+
"test": "playwright test"
3132
},
3233
"devDependencies": {
33-
"http-server": "^14.1.1"
34+
"@playwright/test": "^1.56.1",
35+
"http-server": "^14.1.1",
36+
"playwright": "^1.56.1"
3437
},
3538
"dependencies": {
3639
"roslib": "^2.0.0"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from "@playwright/test";
2+
3+
export default defineConfig({
4+
// Run your local dev server before starting the tests
5+
webServer: {
6+
command: "npm start",
7+
url: "http://localhost:8080",
8+
reuseExistingServer: !process.env.CI,
9+
stdout: "ignore",
10+
stderr: "pipe",
11+
},
12+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { test } from "@playwright/test";
2+
3+
test("ActionClient example initializes", async ({ page }) => {
4+
test.setTimeout(5000);
5+
await page.goto(
6+
`http://localhost:8080/roslib-examples/src/action_client.html`,
7+
);
8+
await page.waitForEvent("console", (msg) =>
9+
msg.text().includes("Connection made!"),
10+
);
11+
});

packages/roslib-examples/src/action_server.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
console.log(error);
1818
});
1919

20+
ros.on("connection", function () {
21+
console.log("Connection made!");
22+
});
23+
2024
// The ActionServer
2125
// ----------------
2226

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { test } from "@playwright/test";
2+
3+
test("SimpleActionServer example initializes", async ({ page }) => {
4+
test.setTimeout(5000);
5+
await page.goto(
6+
`http://localhost:8080/roslib-examples/src/action_server.html`,
7+
);
8+
await page.waitForEvent("console", (msg) =>
9+
msg.text().includes("Connection made!"),
10+
);
11+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { test } from "@playwright/test";
2+
3+
test("ROS 2 Action client example initializes", async ({ page }) => {
4+
test.setTimeout(5000);
5+
await page.goto(
6+
`http://localhost:8080/roslib-examples/src/ros2_action_client.html`,
7+
);
8+
await page.waitForEvent("console", (msg) =>
9+
msg.text().includes("Connection made!"),
10+
);
11+
});

packages/roslib-examples/src/ros2_action_server.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
url: "ws://localhost:9090",
1313
});
1414

15+
ros.on("connection", function () {
16+
console.log("Connection made!");
17+
});
18+
1519
// If there is an error on the backend, an 'error' emit will be emitted.
1620
ros.on("error", function (error) {
1721
console.log(error);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { test } from "@playwright/test";
2+
3+
test("ROS 2 Action server example initializes", async ({ page }) => {
4+
test.setTimeout(5000);
5+
await page.goto(
6+
`http://localhost:8080/roslib-examples/src/ros2_action_server.html`,
7+
);
8+
await page.waitForEvent("console", (msg) =>
9+
msg.text().includes("Connection made!"),
10+
);
11+
});

0 commit comments

Comments
 (0)