-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add driverOptions to be passed per-request * Update README.md * Add example * Run integration tests during test phase * Fix working directory * Emit typescript declarations * Add test for root exports * Better document example file * Swap driver to a simple function * More cleanup * Switch to minimist to simplify CLI * Enhance CLI testing and structuring * Move CLI code into index of cli directory * Move isCrawlerRequest
- Loading branch information
Showing
37 changed files
with
714 additions
and
496 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
node_modules/ | ||
yarn.lock | ||
*.log | ||
nightcrawler.js | ||
dist/ | ||
/nightcrawler.js | ||
dist/ |
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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../dist/cli'); | ||
const cli = require('../dist/cli').default; | ||
const {FailedAnalysisError} = require('../dist/cli/errors') | ||
cli(process.argv, process.stdout, process.cwd()).then( | ||
() => process.exit(0), | ||
(err) => { | ||
console.error(err instanceof FailedAnalysisError ? err.message : err); | ||
process.exit(1); | ||
} | ||
) |
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,2 @@ | ||
package-lock.json | ||
node_modules/ |
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,34 @@ | ||
|
||
const {crawl, test, after} = require('lastcall-nightcrawler'); | ||
const expect = require('expect'); | ||
|
||
module.exports = crawl('Homepage', function() { | ||
const times = []; | ||
|
||
// Tests run for every request/response cycle. | ||
test('Status code is 2xx', function(unit) { | ||
expect(unit.response.statusCode).toBeGreaterThanOrEqual(200); | ||
expect(unit.response.statusCode).toBeLessThan(300); | ||
}); | ||
|
||
test('Has a long cache lifetime', function(unit) { | ||
expect(unit.response.headers).toHaveProperty('cache-control', 'max-age=604800'); | ||
}) | ||
|
||
test('Collect response time', function(unit) { | ||
times.push(unit.response.time); | ||
}) | ||
|
||
// After functions run after all responses have been received. | ||
after('Average response time should be < 200ms', function() { | ||
const sum = times.reduce((total, value) => total + value, 0); | ||
expect(sum / times.length).toBeLessThan(200); | ||
}) | ||
|
||
// Return any iterable/async iterable filled with request-shaped objects. | ||
return [ | ||
// options can be used to pass options to the driver. | ||
// For example, passing {auth: 'foo:bar'} will enable basic auth. | ||
{url: 'https://www.example.com/', options: {}} | ||
] | ||
}) |
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,7 @@ | ||
{ | ||
"name": "lastcall-nightcrawler-examples", | ||
"dependencies": { | ||
"expect": "^25.1.0", | ||
"lastcall-nightcrawler": "^2.0.0" | ||
} | ||
} |
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
Oops, something went wrong.