Skip to content

Commit

Permalink
Updated getBreadcrumbs util to handle pulse enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Olwiba committed May 12, 2020
1 parent 418e5af commit 89153ac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"unused": true,
"boss": true,
"eqnull": true,
"node": true
"node": true,
"esversion": 6
}
14 changes: 1 addition & 13 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ module.exports = function(grunt) {
src: ['src/**/*.js']
}
},
run: {
webdriver: {
cmd: 'npm',
args: [
'run',
'test',
]
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
Expand Down Expand Up @@ -131,13 +122,10 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-run');

grunt.registerTask('test', ['run:webdriver']);

grunt.registerTask('compile', ['jshint', 'clean', 'concat', 'uglify:dist']);

grunt.registerTask('build', ['jshint', 'clean', 'concat', 'string-replace', 'uglify']);

grunt.registerTask('default', ['compile', 'test']);
grunt.registerTask('default', ['compile']);
};
12 changes: 6 additions & 6 deletions tests/specs/breadcrumbs/automatic.xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("XHR tracking", function() {
});

it("tracks XHR start and end events", function() {
var breadcrumbs = common.getBreadcrumbs();
var breadcrumbs = common.getBreadcrumbs(true);

expect(breadcrumbs[0].type).toBe("request");
expect(breadcrumbs[0].message).toContain("Opening request");
Expand All @@ -20,7 +20,7 @@ describe("XHR tracking", function() {
});

it("works when the responseType is non text", function() {
var breadcrumbs = common.getBreadcrumbs();
var breadcrumbs = common.getBreadcrumbs(true);

expect(breadcrumbs[2].type).toBe("request");
expect(breadcrumbs[2].message).toContain("Opening request");
Expand All @@ -30,25 +30,25 @@ describe("XHR tracking", function() {
});

it("records the correct message with the URL", function() {
var breadcrumbs = common.getBreadcrumbs();
var breadcrumbs = common.getBreadcrumbs(true);

expect(breadcrumbs[0].message).toBe("Opening request to http://localhost:4567/fixtures/breadcrumbs/automatic.console.html");
});

it("records the correct requestURL", function() {
var breadcrumbs = common.getBreadcrumbs();
var breadcrumbs = common.getBreadcrumbs(true);

expect(breadcrumbs[0].CustomData.requestURL).toBe("http://localhost:4567/fixtures/breadcrumbs/automatic.console.html");
});

it("records the correct requestURL for absolute paths", function() {
var breadcrumbs = common.getBreadcrumbs();
var breadcrumbs = common.getBreadcrumbs(true);

expect(breadcrumbs[3].CustomData.requestURL).toBe("http://localhost:4567/fixtures/breadcrumbs/automatic.xhr.html");
});

it('does not record requests to raygun domains', function() {
var breadcrumbs = common.getBreadcrumbs();
var breadcrumbs = common.getBreadcrumbs(true);

var doesNotContainRaygun = _.every(breadcrumbs, function (crumb) {
return crumb.CustomData.requestURL.indexOf('raygun') === -1
Expand Down
10 changes: 6 additions & 4 deletions tests/specs/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ module.exports = {
return window.__requestPayloads;
});
},
getBreadcrumbs: function() {
var crumbs = browser.execute(function() {
return window.__requestPayloads[0].Details.Breadcrumbs;
});
getBreadcrumbs: function(pulseEnabled = false) {
var crumbs = browser.execute(function(pulseEnabled) {
return pulseEnabled ?
window.__requestPayloads[(window.__requestPayloads.length - 1)].Details.Breadcrumbs :
window.__requestPayloads[0].Details.Breadcrumbs ;
}, pulseEnabled);

return crumbs;
},
Expand Down

0 comments on commit 89153ac

Please sign in to comment.