-
Notifications
You must be signed in to change notification settings - Fork 212
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
base: matux/vows-to-mocha-2
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
andexpect
- 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; |
There was a problem hiding this comment.
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.
expect(err).to.be.null; | |
expect(err).to.not.exist; |
Copilot uses AI. Check for mistakes.
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(); | ||
}); |
There was a problem hiding this comment.
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.
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.
cce00ad
to
0196ea4
Compare
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