Skip to content

Commit fd0c9a9

Browse files
committed
Update Mockttp for WebSockets (!), private network CORS & raw headers
Note the '.mjs' addition. After updating GraphQL, this is required. Without this, Webpack finds both js & mjs imports, uses both, effectively bundles GraphQL twice, and then the two don't play nicely (e.g. because of instanceof checks across the two).
1 parent 20818b6 commit fd0c9a9

9 files changed

+263
-116
lines changed

package-lock.json

Lines changed: 251 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@
5858
"event-stream": "^4.0.1",
5959
"express": "^4.17.1",
6060
"express-graphql": "^0.11.0",
61-
"graphql": "^14.7.0",
61+
"graphql": "^15.8.0",
6262
"gunzip-maybe": "^1.4.2",
6363
"iconv-lite": "^0.4.24",
6464
"lodash": "^4.17.21",
6565
"lookpath": "^1.2.1",
6666
"mime-types": "^2.1.27",
6767
"mobx": "^6.3.5",
68-
"mockttp": "^2.7.0",
68+
"mockttp": "^3.2.0",
6969
"node-abort-controller": "^3.0.1",
7070
"node-fetch": "^2.6.1",
7171
"node-forge": "^1.3.0",

test/integration-test.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ describe('Integration test', function () {
110110

111111
it('starts a Mockttp server', async () => {
112112
const mockttp = getRemote({
113-
standaloneServerUrl: 'http://localhost:45456',
113+
adminServerUrl: 'http://localhost:45456',
114114
client: {
115115
// Pretend to be a browser on the real site:
116116
headers: { origin: 'https://app.httptoolkit.tech' }
117117
}
118118
});
119119
await mockttp.start();
120-
await mockttp.get('https://google.com').thenReply(200, 'Mock response');
120+
await mockttp.forGet('https://google.com').thenReply(200, 'Mock response');
121121

122122
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
123123
const response = await request.get('https://google.com', { proxy: mockttp.url });

test/interceptors/docker-attachment.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('Docker single-container interceptor', function () {
106106
it(`should intercept external ${target} requests`, async function () {
107107
this.timeout(60000);
108108
const { interceptor, server } = await interceptorSetup;
109-
const mainRule = await server.get('https://example.com').thenReply(404);
109+
const mainRule = await server.forGet('https://example.com').thenReply(404);
110110

111111
const containerId = await buildAndRun(target.toLowerCase(), 'https://example.com');
112112

test/interceptors/electron.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Electron interception', function () {
2323
beforeEach(async () => {
2424
const { server } = await interceptorSetup;
2525
await server.start();
26-
await server.anyRequest().thenPassThrough();
26+
await server.forAnyRequest().thenPassThrough();
2727
});
2828

2929
afterEach(async () => {

test/interceptors/fresh-chrome.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('Chrome interceptor', function () {
1010
beforeEach(async () => {
1111
const { server } = await interceptorSetup;
1212
await server.start();
13-
await server.anyRequest().thenPassThrough();
13+
await server.forAnyRequest().thenPassThrough();
1414
});
1515

1616
afterEach(async () => {

test/interceptors/fresh-firefox.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('Firefox interceptor', function () {
1010
beforeEach(async () => {
1111
const { server } = await interceptorSetup;
1212
await server.start();
13-
await server.anyRequest().thenPassThrough();
13+
await server.forAnyRequest().thenPassThrough();
1414
});
1515

1616
afterEach(async () => {

test/interceptors/fresh-terminal.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Fresh terminal interceptor', function () {
2525

2626
beforeEach(async () => {
2727
const { server } = await interceptorSetup;
28-
await server.anyRequest().thenPassThrough();
28+
await server.forAnyRequest().thenPassThrough();
2929
});
3030

3131
afterEach(async () => {
@@ -44,8 +44,8 @@ describe('Fresh terminal interceptor', function () {
4444

4545
const { server, httpsConfig } = await interceptorSetup;
4646

47-
const mainRule = await server.get(/https?:\/\/example.test\/js\/.*/).thenReply(200);
48-
const stripeRule = await server.get('https://api.stripe.com/v1/customers').thenJson(200, {});
47+
const mainRule = await server.forGet(/https?:\/\/example.test\/js\/.*/).thenReply(200);
48+
const stripeRule = await server.forGet('https://api.stripe.com/v1/customers').thenJson(200, {});
4949

5050
// Spawn node, as if it was run inside an intercepted terminal
5151
const terminalEnvOverrides = getTerminalEnvVars(server.port, httpsConfig, process.env);

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ module.exports = {
106106
new webpack.EnvironmentPlugin({ HTK_IS_BUNDLED: true })
107107
],
108108
resolve: {
109-
extensions: [ '.tsx', '.ts', '.js' ]
109+
extensions: [ '.tsx', '.ts', '.mjs', '.js' ]
110110
}
111111
};

0 commit comments

Comments
 (0)