-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from macbre/milestone-events
Emit events via npm module for certain page loading milestones
- Loading branch information
Showing
8 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Example script that uses phantomas npm module | ||
*/ | ||
var phantomas = require('../'), | ||
run; | ||
|
||
console.log('phantomas v%s loaded from %s', phantomas.version, phantomas.path); | ||
|
||
run = phantomas('http://google.is', { | ||
'analyze-css': true, | ||
'assert-requests': 1 | ||
}); | ||
|
||
console.log('Running phantomas: pid %d', run.pid); | ||
|
||
// errors handling | ||
run.on('error', function(code) { | ||
console.log('Exit code #%d', code); | ||
}); | ||
|
||
// handle results | ||
run.on('results', function(results) { | ||
console.log('Number of requests: %d', results.getMetric('requests')); | ||
console.log('Failed asserts: %j', results.getFailedAsserts()); | ||
}); | ||
|
||
// events handling | ||
run.on('progress', function(progress) { | ||
console.log('Loading progress: %d%', progress); | ||
}); | ||
|
||
run.on('milestone', function(milestone, timing) { | ||
console.log('%s at %d ms', milestone, timing); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters