Skip to content

Commit

Permalink
Fix default HTTP client tests (Azure#321)
Browse files Browse the repository at this point in the history
* Enable CORS

* Add empty line

* Add mock http proxy

* Fix few tests

* Remove axios workaround that was fixed in current release

* Fix all tests except download/upload progress

* Fix stream HTTP tests

* Delete testserver

* Remove reporting skipped tests as warning

* Remove .only

* Add nodeIt

* Fix Constants.ts

* Remove it.skip()
  • Loading branch information
kpajdzik authored Jan 22, 2019
1 parent 2bc787a commit 4c2b1c5
Show file tree
Hide file tree
Showing 11 changed files with 369 additions and 227 deletions.
5 changes: 1 addition & 4 deletions .scripts/checkEverything.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { checkEverything } from "@ts-common/azure-js-dev-tools";
import { checkConstantsVersion } from "./checkConstantsVersion";

checkEverything({
checkForSkipCallsOptions: {
skipIsWarning: true
},
additionalChecks: {
name: "Constants.ts Version",
check: checkConstantsVersion
}
});
});
6 changes: 5 additions & 1 deletion karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ module.exports = function (config: any) {
concurrency: Infinity,

customLaunchers: {
ChromeNoSecurity: {
base: "ChromeHeadless",
flags: ["--disable-web-security"]
},
ChromeDebugging: {
base: "Chrome",
flags: [`http://localhost:${defaults.port}/debug.html`, "--auto-open-devtools-for-tabs"]
flags: [`http://localhost:${defaults.port}/debug.html`, "--auto-open-devtools-for-tabs", "--disable-web-security"]
}
},
});
Expand Down
4 changes: 1 addition & 3 deletions lib/axiosHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import { RestError } from "./restError";
import { WebResource, HttpRequestBody } from "./webResource";
import { ProxySettings } from "./serviceClient";

const axiosClient = axios.create();
// Workaround for https://github.com/axios/axios/issues/1158
axiosClient.interceptors.request.use(config => ({ ...config, method: config.method && config.method.toUpperCase() as any }));
export const axiosClient = axios.create();

/**
* A HttpClient implementation that uses axios to send HTTP requests.
Expand Down
2 changes: 1 addition & 1 deletion lib/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Constants = {
* @const
* @type {string}
*/
msRestVersion: "1.5.0",
msRestVersion: "1.5.1",

/**
* Specifies HTTP.
Expand Down
2 changes: 1 addition & 1 deletion mocha.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"reporterEnabled": "list, mocha-junit-reporter"
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "azsdkteam@microsoft.com",
"url": "https://github.com/Azure/ms-rest-js"
},
"version": "1.5.0",
"version": "1.5.1",
"description": "Isomorphic client Runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest",
"tags": [
"isomorphic",
Expand Down Expand Up @@ -73,6 +73,7 @@
"@types/xhr-mock": "^2.0.0",
"@types/xml2js": "^0.4.3",
"abortcontroller-polyfill": "^1.1.9",
"axios-mock-adapter": "^1.16.0",
"chai": "^4.2.0",
"express": "^4.16.3",
"glob": "^7.1.2",
Expand Down Expand Up @@ -111,6 +112,7 @@
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2",
"webpack-dev-middleware": "^3.1.2",
"xhr-mock": "^2.4.1",
"yarn": "^1.6.0"
},
"homepage": "https://github.com/Azure/ms-rest-js",
Expand All @@ -132,7 +134,7 @@
"test": "run-p test:tslint test:unit test:karma",
"test:tslint": "tslint -p . -c tslint.json --exclude \"./test/**/*.ts\"",
"test:unit": "nyc mocha",
"test:karma": "npm run build:test-browser && node ./node_modules/karma/bin/karma start karma.conf.ts --single-run",
"test:karma": "npm run build:test-browser && node ./node_modules/karma/bin/karma start karma.conf.ts --browsers ChromeNoSecurity --single-run ",
"test:karma:debug": "npm run build:test-browser && node ./node_modules/karma/bin/karma start karma.conf.ts --log-level debug --browsers ChromeDebugging --debug --auto-watch",
"publish-preview": "mocha --no-colors && shx rm -rf dist/test && node ./.scripts/publish",
"local": "ts-node ./.scripts/local.ts",
Expand Down
Loading

0 comments on commit 4c2b1c5

Please sign in to comment.