Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules
dist
importmap.js
.DS_Store
test-results
91 changes: 85 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/roslib-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
}
],
"scripts": {
"start": "http-server .. -o /roslib-examples/src/index.html"
"start": "http-server .. -o /roslib-examples/src/index.html",
"test": "playwright install --with-deps && playwright test"
},
"devDependencies": {
"http-server": "^14.1.1"
"@playwright/test": "^1.56.1",
"http-server": "^14.1.1",
"playwright": "^1.56.1"
},
"dependencies": {
"roslib": "^2.0.0"
Expand Down
12 changes: 12 additions & 0 deletions packages/roslib-examples/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "@playwright/test";

export default defineConfig({
// Run your local dev server before starting the tests
webServer: {
command: "npm start",
url: "http://localhost:8080",
reuseExistingServer: !process.env.CI,
stdout: "ignore",
stderr: "pipe",
},
});
11 changes: 11 additions & 0 deletions packages/roslib-examples/src/action_client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test } from "@playwright/test";

test("ActionClient example initializes", async ({ page }) => {
test.setTimeout(5000);
await page.goto(
`http://localhost:8080/roslib-examples/src/action_client.html`,
);
await page.waitForEvent("console", (msg) =>
msg.text().includes("Connection made!"),
);
});
4 changes: 4 additions & 0 deletions packages/roslib-examples/src/action_server.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
console.log(error);
});

ros.on("connection", function () {
console.log("Connection made!");
});

// The ActionServer
// ----------------

Expand Down
11 changes: 11 additions & 0 deletions packages/roslib-examples/src/action_server.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test } from "@playwright/test";

test("SimpleActionServer example initializes", async ({ page }) => {
test.setTimeout(5000);
await page.goto(
`http://localhost:8080/roslib-examples/src/action_server.html`,
);
await page.waitForEvent("console", (msg) =>
msg.text().includes("Connection made!"),
);
});
11 changes: 11 additions & 0 deletions packages/roslib-examples/src/ros2_action_client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test } from "@playwright/test";

test("ROS 2 Action client example initializes", async ({ page }) => {
test.setTimeout(5000);
await page.goto(
`http://localhost:8080/roslib-examples/src/ros2_action_client.html`,
);
await page.waitForEvent("console", (msg) =>
msg.text().includes("Connection made!"),
);
});
4 changes: 4 additions & 0 deletions packages/roslib-examples/src/ros2_action_server.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
url: "ws://localhost:9090",
});

ros.on("connection", function () {
console.log("Connection made!");
});

// If there is an error on the backend, an 'error' emit will be emitted.
ros.on("error", function (error) {
console.log(error);
Expand Down
11 changes: 11 additions & 0 deletions packages/roslib-examples/src/ros2_action_server.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test } from "@playwright/test";

test("ROS 2 Action server example initializes", async ({ page }) => {
test.setTimeout(5000);
await page.goto(
`http://localhost:8080/roslib-examples/src/ros2_action_server.html`,
);
await page.waitForEvent("console", (msg) =>
msg.text().includes("Connection made!"),
);
});
9 changes: 9 additions & 0 deletions packages/roslib-examples/src/ros2_simple.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test } from "@playwright/test";

test("ROS 2 simple example initializes", async ({ page }) => {
test.setTimeout(5000);
await page.goto(`http://localhost:8080/roslib-examples/src/ros2_simple.html`);
await page.waitForEvent("console", (msg) =>
msg.text().includes("Connection made!"),
);
});
9 changes: 9 additions & 0 deletions packages/roslib-examples/src/simple.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test } from "@playwright/test";

test("Simple example initializes", async ({ page }) => {
test.setTimeout(5000);
await page.goto(`http://localhost:8080/roslib-examples/src/simple.html`);
await page.waitForEvent("console", (msg) =>
msg.text().includes("Connection made!"),
);
});
31 changes: 31 additions & 0 deletions packages/roslib-test-backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "roslib-test-backend",
"version": "2.0.0",
"description": "Integration test backend for roslib",
"homepage": "https://github.com/RobotWebTools/roslibjs#readme",
"bugs": {
"url": "https://github.com/RobotWebTools/roslibjs/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/RobotWebTools/roslibjs.git"
},
"license": "BSD-2-Clause",
"author": "Robot Webtools Team <robot-web-tools@googlegroups.com> (https://robotwebtools.github.io)",
"contributors": [
{
"name": "Ezra Brooks",
"email": "ezra@brooks.cx",
"url": "https://github.com/EzraBrooks"
}
],
"type": "module",
"main": "ros-backend.ts",
"peerDependencies": {
"roslib": "^2.0.0"
},
"devDependencies": {
"@types/dockerode": "^3.3.47",
"dockerode": "^4.0.9"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import Docker from "dockerode";
import Ros from "../../src/core/Ros.ts";
import { Ros } from "roslib";

const CONTAINER_NAME = "roslibjs-test-backend";
const CONTAINER_PORT = 9090;
Expand Down
3 changes: 1 addition & 2 deletions packages/roslib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
"devDependencies": {
"@eslint/js": "^9.32.0",
"@testing-library/react": "^16.0.0",
"@types/dockerode": "^3.3.45",
"@types/node": "^24.0.1",
"@types/ws": "^8.5.10",
"changelog-maker": "^4.4.5",
"dockerode": "^4.0.9",
"eslint": "^9.32.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.32.0",
Expand All @@ -32,6 +30,7 @@
"jiti": "^2.6.1",
"jsdom": "^27.0.0",
"jspm": "^4.2.0",
"roslib-test-backend": "^2.0.0",
"typedoc": "^0.28.14",
"typescript": "^5.9.2",
"typescript-eslint": "^8.39.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/roslib/test/setup/vitest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file sets up and tears down the ROS backend container for all tests
*/

import { setupBackend, teardownBackend } from "./ros-backend.ts";
import { setupBackend, teardownBackend } from "roslib-test-backend";

// Global setup - runs once before all tests
export async function setup() {
Expand Down
Loading