Skip to content

Commit 3690b34

Browse files
committed
Use local HTTP server for most testing.
- Use a local HTTP server for most testing. - Use httpbin for valid cert HTTPS testing. - Add local server self-signed certificate HTTPS test.
1 parent ab56628 commit 3690b34

10 files changed

+352
-50
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @digitalbazaar/http-client ChangeLog
22

3+
## 3.4.1 - 2023-04-xx
4+
5+
### Changed
6+
- Use a local HTTP server for most testing.
7+
- Use httpbin for valid cert HTTPS testing.
8+
- Add local server self-signed certificate HTTPS test.
9+
310
## 3.4.0 - 2023-04-14
411

512
### Changed

karma.conf.cjs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
/*
2-
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2020-2023 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
module.exports = function(config) {
4+
5+
const {startServers} = require('./tests/utils.cjs');
6+
const webpack = require('webpack');
7+
8+
module.exports = async function(config) {
9+
const {
10+
//httpServer,
11+
//httpsServer,
12+
httpHost: testHttpHost,
13+
httpsHost: testHttpsHost,
14+
} = await startServers();
515

616
config.set({
717
// base path that will be used to resolve all patterns (eg. files, exclude)
@@ -27,7 +37,13 @@ module.exports = function(config) {
2737
webpack: {
2838
//mode: 'production',
2939
mode: 'development',
30-
devtool: 'inline-source-map'
40+
devtool: 'inline-source-map',
41+
plugins: [
42+
new webpack.DefinePlugin({
43+
'process.env.TEST_HTTP_HOST': JSON.stringify(testHttpHost),
44+
'process.env.TEST_HTTPS_HOST': JSON.stringify(testHttpsHost)
45+
})
46+
]
3147
},
3248

3349
// test results reporter to use

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"import": "./lib/index.js"
1111
},
1212
"browser": {
13-
"./lib/agentCompatibility.js": "./lib/agentCompatibility-browser.js"
13+
"./lib/agentCompatibility.js": "./lib/agentCompatibility-browser.js",
14+
"./tests/utils.cjs": "./tests/utils-browser.cjs"
1415
},
1516
"scripts": {
1617
"rollup": "rollup -c rollup.config.js",
@@ -40,12 +41,15 @@
4041
"devDependencies": {
4142
"c8": "^7.13.0",
4243
"chai": "^4.3.7",
44+
"cors": "^2.8.5",
4345
"cross-env": "^7.0.3",
46+
"delay": "^5.0.0",
4447
"detect-node": "^2.1.0",
4548
"eslint": "^8.38.0",
4649
"eslint-config-digitalbazaar": "^4.2.0",
4750
"eslint-plugin-jsdoc": "^41.1.1",
4851
"eslint-plugin-unicorn": "^46.0.0",
52+
"express": "^4.18.2",
4953
"karma": "^6.4.1",
5054
"karma-chai": "^0.1.0",
5155
"karma-chrome-launcher": "^3.1.1",

tests/10-client-api.spec.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/*!
2-
* Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2020-2023 Digital Bazaar, Inc. All rights reserved.
33
*/
44
const {kyPromise, httpClient, DEFAULT_HEADERS} = require('..');
55
const isNode = require('detect-node');
66
const {test} = require('./10-client-api.spec.common.cjs');
7+
const utils = require('./utils.cjs');
78

8-
test({kyPromise, httpClient, DEFAULT_HEADERS, isNode});
9+
test({kyPromise, httpClient, DEFAULT_HEADERS, isNode, utils});

0 commit comments

Comments
 (0)