Skip to content

Commit 17a1e85

Browse files
authored
Fix test-type-description-service.js flakiness (#1155)
This PR addresses the flakiness in the test-type-description-service.js test suite by updating the asynchronous initialization pattern. - Converts beforeEach to an async function, awaiting rclnodejs.init() - Creates and spins a test node in beforeEach instead of within individual tests Fix: #1154
1 parent f2dd1f0 commit 17a1e85

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/test-type-description-service.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ const TypeDescriptionService = require('../lib/type_description_service.js');
2121

2222
describe('type description service test suite', function () {
2323
this.timeout(60 * 1000);
24+
let node;
2425

25-
beforeEach(function () {
26-
return rclnodejs.init();
26+
beforeEach(async function () {
27+
await rclnodejs.init();
28+
const nodeName = 'test_type_description_service';
29+
node = rclnodejs.createNode(nodeName);
30+
rclnodejs.spin(node);
2731
});
2832

2933
afterEach(function () {
@@ -35,9 +39,7 @@ describe('type description service test suite', function () {
3539
this.skip();
3640
return;
3741
}
38-
// Create a node and a publisher
39-
const nodeName = 'test_type_description_service';
40-
const node = rclnodejs.createNode(nodeName);
42+
// Create a publisher
4143
const topic = 'test_get_type_description_publisher';
4244
const topicType = 'std_msgs/msg/String';
4345
node.createPublisher(topicType, topic);
@@ -66,6 +68,5 @@ describe('type description service test suite', function () {
6668
assert.notStrictEqual(response.type_sources.length, 0);
6769
done();
6870
});
69-
rclnodejs.spin(node);
7071
});
7172
});

0 commit comments

Comments
 (0)