Skip to content
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

feat: Convert recordings to be HAR compliant #45

Merged
merged 26 commits into from
Jul 1, 2018
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9dac9c3
feat: Har initial commit
offirgolan Jun 21, 2018
ef48f9f
Merge branch 'master' into har
offirgolan Jun 21, 2018
2f5c2a9
feat: Har checkpoint
offirgolan Jun 22, 2018
6271086
Merge branch 'master' into har
offirgolan Jun 25, 2018
c52b8a4
feat: Http entity base class and HTTP Headers util
offirgolan Jun 25, 2018
fcffedb
Merge branch 'master' into har
offirgolan Jun 26, 2018
31a428a
chore: Checkpoint
offirgolan Jun 26, 2018
422cdc4
test: Get all the tests to pass
offirgolan Jun 26, 2018
bc03876
fix: Eslint errors
offirgolan Jun 26, 2018
fb86f90
chore: Fix linting
offirgolan Jun 26, 2018
9981836
test: Add HTTPHeaders & HTTPEntity tests
offirgolan Jun 26, 2018
e75978d
chore: Re-add commitmsg
offirgolan Jun 26, 2018
f77912e
fix: Use .har filename
offirgolan Jun 26, 2018
bc6f5bf
chore: Fix eslint issue
offirgolan Jun 26, 2018
bb11788
fix: Correctly handle non text bodies and blob serialization
offirgolan Jun 26, 2018
f47a771
chore: Moves utf8-byte-length to npm dep
jasonmit Jun 26, 2018
8f4edc3
chore: Use utf8-byte-length npm package
offirgolan Jun 26, 2018
6b9feb3
Merge branch 'master' into har
offirgolan Jun 27, 2018
70b0328
chore: Remove har package
offirgolan Jun 27, 2018
0552425
Merge branch 'master' into har
offirgolan Jun 27, 2018
d4c7477
test: Add faling har-validator test
offirgolan Jun 29, 2018
e79ce84
chore: Rename HTTPEntity to HTTPBase, add tests & docs
offirgolan Jun 29, 2018
84c9458
test: Fix build to use har-validator
offirgolan Jun 29, 2018
64cf7ce
chore: Rename config method names
offirgolan Jun 30, 2018
42751d8
test: Add addEntries and sortEntries test cases
offirgolan Jun 30, 2018
e1f6012
Merge branch 'master' into har
offirgolan Jul 1, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 57 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,74 @@ describe('Netflix Homepage', function() {
});
```

The above test case would generate the following recording which Polly will use to replay the sign-in request/response when the test is rerun:
The above test case would generate the following recording HAR which Polly will use to replay the sign-in request/response when the test is rerun:

```json
{
"created_at": "2018-06-01T20:36:46.198Z",
"entries": {
"1077f062f8b12b51733933f86fb7ebc4": [
"log": {
"_recordingName": "Sign In",
"browser": {
"name": "Chrome",
"version": "67.0"
},
"creator": {
"name": "Polly.JS",
"version": "0.5.0"
},
"entries": [
{
"created_at": "2018-06-01T20:36:46.198Z",
"_id": "06f06e6d125cbb80896c41786f9a696a",
"_order": 0,
"cache": {},
"request": {
"body": "{\"email\":\"[email protected]\",\"password\":\"@pollyjs\"}",
"headers": {
"Content-Type": "application/json;charset=utf-8"
},
"bodySize": 51,
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json; charset=utf-8"
}
],
"headersSize": 97,
"httpVersion": "HTTP/1.1",
"method": "POST",
"timestamp": "2018-06-01T20:36:46.070Z",
"url": "/api/v1/login"
"postData": {
"mimeType": "application/json; charset=utf-8",
"text": "{\"email\":\"[email protected]\",\"password\":\"@pollyjs\"}"
},
"queryString": [],
"url": "https://netflix.com/api/v1/login"
},
"response": {
"body": "",
"headers": {},
"bodySize": 0,
"content": {
"mimeType": "text/plain; charset=utf-8",
"size": 0
},
"cookies": [],
"headers": [],
"headersSize": 0,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"timestamp": "2018-06-01T20:36:46.119Z"
"statusText": "OK"
},
"startedDateTime": "2018-06-29T17:31:55.348Z",
"time": 11,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 11
}
}
]
},
"name": "Sign In",
"schema_version": 0.1
],
"pages": [],
"version": "1.2"
}
}
```

Expand Down
21 changes: 16 additions & 5 deletions build-scripts/rollup.browser.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ import deepmerge from 'deepmerge';
import alias from 'rollup-plugin-alias';
import babel from 'rollup-plugin-babel';
import { rollup as lerna } from 'lerna-alias';
import resolve from 'rollup-plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import builtins from 'rollup-plugin-node-builtins';
import createCommonConfig, { output, pkg } from './rollup.common.config';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import json from 'rollup-plugin-json';
import { input, output, pkg, production } from './rollup.utils';

export default function createClientConfig(options = {}, targets) {
return deepmerge(
createCommonConfig({
{
input,
output: deepmerge(output('umd'), { name: pkg.name }),
plugins: [
alias(lerna()),
builtins(),
json(),
resolve({ browser: true }),
commonjs(),
babel({
babelrc: false,
runtimeHelpers: true,
Expand All @@ -33,7 +41,10 @@ export default function createClientConfig(options = {}, targets) {
],
exclude: ['node_modules/**'],
ignore: 'node_modules/**'
})
}),
globals(),
builtins(),
production && uglify()
],
onwarn(message) {
/* nise uses eval for strings within native fns setTimeout('alert("foo")', 10) */
Expand All @@ -43,7 +54,7 @@ export default function createClientConfig(options = {}, targets) {

console.error(message);
}
}),
},
options
);
}
12 changes: 2 additions & 10 deletions build-scripts/rollup.browser.test.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import deepmerge from 'deepmerge';
import multiEntry from 'rollup-plugin-multi-entry';
import createClientConfig from './rollup.browser.config';
import { pkg } from './rollup.common.config';
import { pkg } from './rollup.utils';

export default function createClientTestConfig(options = {}) {
return deepmerge(
Expand All @@ -18,15 +18,7 @@ export default function createClientTestConfig(options = {}) {
`,
outro: '});'
},
plugins: [multiEntry()],
onwarn(warning) {
if (
warning.code !== 'CIRCULAR_DEPENDENCY' &&
!(/nise/.test(warning) && /eval/.test(warning))
) {
console.error(`(!) ${warning.message}`);
}
}
plugins: [multiEntry()]
},
/* target override */
{
Expand Down
47 changes: 0 additions & 47 deletions build-scripts/rollup.common.config.js

This file was deleted.

19 changes: 14 additions & 5 deletions build-scripts/rollup.node.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import createConfig, { output, pkg } from './rollup.common.config';
import babel from 'rollup-plugin-babel';
import deepmerge from 'deepmerge';
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import json from 'rollup-plugin-json';
import { input, output, pkg, production } from './rollup.utils';

const external = Object.keys(pkg.dependencies || {});

export default function createServerConfig(options = {}) {
return deepmerge(
createConfig({
{
input,
output: [output('cjs'), output('es')],
external,
plugins: [
json(),
resolve(),
commonjs(),
babel({
babelrc: false,
runtimeHelpers: true,
Expand All @@ -31,9 +39,10 @@ export default function createServerConfig(options = {}) {
],
exclude: ['node_modules/**'],
ignore: 'node_modules/**'
})
}),
production && uglify()
]
}),
},
options
);
}
26 changes: 26 additions & 0 deletions build-scripts/rollup.utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* globals require process */

import path from 'path';

export const pkg = require(path.resolve(process.cwd(), './package.json'));
export const production = process.env.NODE_ENV === 'production';
export const input = './src/index.js';

const banner = `/**
* ${pkg.name} v${pkg.version}
*
* https://github.com/netflix/pollyjs
*
* Released under the ${pkg.license} License.
*/`;

export const output = format => {
return {
format,
file: `./dist/${format}/${pkg.name.replace('@pollyjs/', 'pollyjs-')}.${
production ? 'min.js' : 'js'
}`,
sourcemap: production,
banner
};
};
77 changes: 58 additions & 19 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,36 +81,75 @@ describe('Netflix Homepage', function() {
});
```

The above test case would generate the following recording which Polly will use
to replay the sign-in request/response when the test is rerun:
The above test case would generate the following recording HAR which Polly will
use to replay the sign-in request/response when the test is rerun:

```json
{
"created_at": "2018-06-01T20:36:46.198Z",
"entries": {
"1077f062f8b12b51733933f86fb7ebc4": [
"log": {
"_recordingName": "Sign In",
"browser": {
"name": "Chrome",
"version": "67.0"
},
"creator": {
"name": "Polly.JS",
"version": "0.5.0"
},
"entries": [
{
"created_at": "2018-06-01T20:36:46.198Z",
"_id": "06f06e6d125cbb80896c41786f9a696a",
"_order": 0,
"cache": {},
"request": {
"body": "{\"email\":\"[email protected]\",\"password\":\"@pollyjs\"}",
"headers": {
"Content-Type": "application/json;charset=utf-8"
},
"bodySize": 51,
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json; charset=utf-8"
}
],
"headersSize": 97,
"httpVersion": "HTTP/1.1",
"method": "POST",
"timestamp": "2018-06-01T20:36:46.070Z",
"url": "/api/v1/login"
"postData": {
"mimeType": "application/json; charset=utf-8",
"text": "{\"email\":\"[email protected]\",\"password\":\"@pollyjs\"}"
},
"queryString": [],
"url": "https://netflix.com/api/v1/login"
},
"response": {
"body": "",
"headers": {},
"bodySize": 0,
"content": {
"mimeType": "text/plain; charset=utf-8",
"size": 0
},
"cookies": [],
"headers": [],
"headersSize": 0,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"timestamp": "2018-06-01T20:36:46.119Z"
"statusText": "OK"
},
"startedDateTime": "2018-06-29T17:31:55.348Z",
"time": 11,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 11
}
}
]
},
"name": "Sign In",
"schema_version": 0.1
],
"pages": [],
"version": "1.2"
}
}
```

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-multi-entry": "^2.0.2",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.2.1",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-uglify": "^3.0.0",
"start-server-and-test": "^1.4.1",
Expand Down
Loading