Skip to content

Commit

Permalink
test: wrap network tests in timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjones committed Aug 1, 2022
1 parent acbb257 commit c64b268
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
21 changes: 12 additions & 9 deletions test/examples/universalBrowser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ describe('Rollbar loaded by snippet', function() {
);

var ret = rollbar.info('test');
server.respond();

var body = JSON.parse(server.requests[0].requestBody);
setTimeout(function() {
server.respond();

var body = JSON.parse(server.requests[0].requestBody);

expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
expect(body.data.uuid).to.eql(ret.uuid);
expect(body.data.body.message.body).to.eql('test');
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
expect(body.data.uuid).to.eql(ret.uuid);
expect(body.data.body.message.body).to.eql('test');

// Assert load telemetry was added.
expect(body.data.body.telemetry[0].type).to.eql('navigation');
expect(body.data.body.telemetry[0].body.subtype).to.eql('DOMContentLoaded');
// Assert load telemetry was added.
expect(body.data.body.telemetry[0].type).to.eql('navigation');
expect(body.data.body.telemetry[0].body.subtype).to.eql('DOMContentLoaded');

done();
done();
}, 1);
});
});
21 changes: 12 additions & 9 deletions test/examples/universalBrowserConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ describe('Rollbar loaded by snippet with non-default options', function() {
);

var ret = rollbar.info('test');
server.respond();

var body = JSON.parse(server.requests[0].requestBody);
setTimeout(function() {
server.respond();

var body = JSON.parse(server.requests[0].requestBody);

expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
expect(body.data.uuid).to.eql(ret.uuid);
expect(body.data.body.message.body).to.eql('test');
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
expect(body.data.uuid).to.eql(ret.uuid);
expect(body.data.body.message.body).to.eql('test');

// Assert that load telemetry was not added. (First event is the log event.)
expect(body.data.body.telemetry[0].type).to.eql('log');
expect(body.data.body.telemetry[0].body.message).to.eql('test');
// Assert that load telemetry was not added. (First event is the log event.)
expect(body.data.body.telemetry[0].type).to.eql('log');
expect(body.data.body.telemetry[0].body.message).to.eql('test');

done();
done();
}, 1);
});
});

0 comments on commit c64b268

Please sign in to comment.