Skip to content

Migrate server transport test #1210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: matux/vows-to-mocha-2
Choose a base branch
from

Conversation

matux
Copy link
Contributor

@matux matux commented Jun 4, 2025

Description of the change

This PR migrates the server test transport to mocha from vows.

Related issues

SDK-490/migrate-vowsjs-to-mocha
SDK-491/complete-server-test-es-module-migration

@matux matux requested a review from Copilot June 4, 2025 20:11
@matux matux self-assigned this Jun 4, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Migrate the server transport tests from Vows.js to Mocha with Chai assertions

  • Remove the legacy vows-based test suite
  • Add a new ES module–based Mocha test file using describe/it and expect
  • Replicate existing test scenarios (payload handling, error cases, rate limiting) in the new framework

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/server.transport.test.js Deleted old Vows.js–based transport tests
test/server.transport.mocha.test.js Added new Mocha/Chai–based transport tests

{},
'payload',
function (err) {
expect(err).to.be.null;
Copy link
Preview

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using expect(err).to.be.null may fail if err is undefined. Prefer expect(err).to.not.exist for clarity and to cover both null and undefined cases.

Suggested change
expect(err).to.be.null;
expect(err).to.not.exist;

Copilot uses AI. Check for mistakes.

Comment on lines +331 to +337
transport.post('token', {}, 'payload', function (err) {
expect(err.message).to.match(/Exceeded rate limit/);
expect(Math.floor(Date.now() / 1000)).to.be.below(
transport.rateLimitExpires,
);
done();
});
Copy link
Preview

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test calls transport.post without providing the stubbed transportFactory, which may trigger real HTTP requests. Add a factory argument to isolate and stub out external calls.

Suggested change
transport.post('token', {}, 'payload', function (err) {
expect(err.message).to.match(/Exceeded rate limit/);
expect(Math.floor(Date.now() / 1000)).to.be.below(
transport.rateLimitExpires,
);
done();
});
const factory = transportFactory(
new Error('Exceeded rate limit'),
null,
);
transport.post('token', {}, 'payload', function (err) {
expect(err.message).to.match(/Exceeded rate limit/);
expect(Math.floor(Date.now() / 1000)).to.be.below(
transport.rateLimitExpires,
);
done();
}, factory);

Copilot uses AI. Check for mistakes.

@matux matux force-pushed the matux/vows-to-mocha-3 branch from cce00ad to 0196ea4 Compare June 4, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants