Skip to content

Commit

Permalink
Update to mocha 7 (#8108)
Browse files Browse the repository at this point in the history
* Update to mocha 7

Fix tests by skipping afterEach steps that are now running in 7 that weren't before.
  • Loading branch information
xirzec committed Mar 31, 2020
1 parent 8f4f3bc commit b659e18
Show file tree
Hide file tree
Showing 46 changed files with 300 additions and 221 deletions.
282 changes: 162 additions & 120 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions common/tools/eslint-plugin-azure-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@types/eslint": "^4.16.8",
"@types/estree": "0.0.39",
"@types/glob": "^7.1.1",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/experimental-utils": "^2.0.0",
Expand All @@ -81,7 +81,7 @@
"bluebird": "^3.5.5",
"chai": "^4.2.0",
"eslint": "^6.1.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
Expand Down
4 changes: 2 additions & 2 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/sinon": "^7.0.13",
"assert": "^1.4.1",
Expand All @@ -97,7 +97,7 @@
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-no-only-tests": "^2.3.0",
"eslint-plugin-promise": "^4.1.1",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nock": "^11.7.0",
"nyc": "^14.0.0",
Expand Down
6 changes: 4 additions & 2 deletions sdk/appconfiguration/app-configuration/test/etags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ describe("etags", () => {
});
});

afterEach(async () => {
await deleteKeyCompletely([key], client);
afterEach(async function() {
if (!this.currentTest?.isPending()) {
await deleteKeyCompletely([key], client);
}
});

// etag usage is 'opt-in' via the onlyIfChanged/onlyIfUnchanged options for certain calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("AppConfigurationClient (set|clear)ReadOnly", () => {
});

after(async function() {
if (!this.currentTest!.isPending) {
if (!this.currentTest?.isPending()) {
await deleteKeyCompletely([testConfigSetting.key], client);
}
});
Expand Down
16 changes: 10 additions & 6 deletions sdk/appconfiguration/app-configuration/test/internal/http.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ describe("http request related tests", () => {
scope = nock(/.*/);
});

afterEach(() => {
assert.ok(scope.isDone());
nock.cleanAll();
afterEach(function() {
if (!this.currentTest?.isPending()) {
assert.ok(scope.isDone());
nock.cleanAll();
}
});

it("custom client request ID", async () => {
Expand Down Expand Up @@ -178,9 +180,11 @@ describe("http request related tests", () => {
scope = nock(/.*/);
});

afterEach(() => {
assert.ok(scope.isDone());
nock.cleanAll();
afterEach(function() {
if (!this.currentTest?.isPending()) {
assert.ok(scope.isDone());
nock.cleanAll();
}
});

it("policy is setup properly to send sync tokens", async function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ describe("Various error cases", () => {
nonExistentKey = "non-existent key " + addedSetting.key;
});

afterEach(async () => {
await deleteKeyCompletely([addedSetting.key], client);
afterEach(async function() {
if (!this.currentTest?.isPending()) {
await deleteKeyCompletely([addedSetting.key], client);
}
});

it("get: Non-existent key throws 404", async () => {
Expand Down Expand Up @@ -90,8 +92,10 @@ describe("Various error cases", () => {
nonExistentKey = "bogus key " + addedSetting.key;
});

afterEach(async () => {
await deleteKeyCompletely([addedSetting.key], client);
afterEach(async function() {
if (!this.currentTest?.isPending()) {
await deleteKeyCompletely([addedSetting.key], client);
}
});

it("get: value is unchanged from etag (304) using ifNoneMatch, sets all properties to undefined", async () => {
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/abort-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
Expand All @@ -95,7 +95,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@types/chai-as-promised": "^7.1.0",
"@types/debug": "^4.1.4",
"@types/jssha": "^2.0.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/sinon": "^7.0.13",
"@typescript-eslint/eslint-plugin": "^2.0.0",
Expand All @@ -105,7 +105,7 @@
"karma": "^4.0.1",
"karma-chrome-launcher": "^3.0.0",
"karma-mocha": "^1.3.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-arm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"devDependencies": {
"@rollup/plugin-node-resolve": "^7.0.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
Expand All @@ -115,7 +115,7 @@
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-no-only-tests": "^2.3.0",
"eslint-plugin-promise": "^4.1.1",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"npm-run-all": "^4.1.5",
"nyc": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
Expand All @@ -80,7 +80,7 @@
"eslint-plugin-no-only-tests": "^2.3.0",
"eslint-plugin-promise": "^4.1.1",
"inherits": "^2.0.3",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"@types/express": "^4.16.0",
"@types/glob": "^7.1.1",
"@types/karma": "^3.0.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/sinon": "^7.0.13",
"@types/tough-cookie": "^2.3.5",
Expand All @@ -181,7 +181,7 @@
"karma-mocha": "^1.3.0",
"karma-rollup-preprocessor": "^7.0.0",
"karma-sourcemap-loader": "^0.3.7",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-chrome": "^2.0.0",
"mocha-junit-reporter": "^1.18.0",
"npm-run-all": "^4.1.5",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-lro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
Expand All @@ -131,7 +131,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"npm-run-all": "^4.1.5",
"nyc": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-tracing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
Expand All @@ -82,7 +82,7 @@
"eslint-plugin-no-only-tests": "^2.3.0",
"eslint-plugin-promise": "^4.1.1",
"inherits": "^2.0.3",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/sinon": "^7.0.13",
"@typescript-eslint/eslint-plugin": "^2.0.0",
Expand All @@ -103,7 +103,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmosdb/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@types/fast-json-stable-stringify": "^2.0.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/node-fetch": "^2.5.0",
"@types/priorityqueuejs": "^1.0.1",
Expand All @@ -120,7 +120,7 @@
"eslint-plugin-promise": "^4.1.1",
"esm": "^3.2.18",
"execa": "^3.3.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"prettier": "^1.16.4",
"proxy-agent": "^3.1.1",
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventhub/event-hubs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"@types/chai-string": "^1.4.1",
"@types/debug": "^4.1.4",
"@types/long": "^4.0.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/sinon": "^7.0.13",
"@types/uuid": "^3.4.3",
Expand Down Expand Up @@ -133,7 +133,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventhub/event-processor-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@types/chai-as-promised": "^7.1.0",
"@types/chai-string": "^1.4.1",
"@types/debug": "^4.1.4",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/uuid": "^3.4.3",
"@types/ws": "^6.0.1",
Expand All @@ -106,7 +106,7 @@
"eslint-plugin-promise": "^4.1.1",
"esm": "^3.2.18",
"https-proxy-agent": "^3.0.1",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventhub/eventhubs-checkpointstore-blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@types/chai-as-promised": "^7.1.0",
"@types/chai-string": "^1.4.1",
"@types/debug": "^4.1.4",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
Expand Down Expand Up @@ -107,7 +107,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/identity/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@rollup/plugin-replace": "^2.2.0",
"@types/express": "^4.16.0",
"@types/jws": "^3.2.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/qs": "^6.5.3",
"@types/uuid": "^3.4.3",
Expand All @@ -116,7 +116,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"open": "^7.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/keyvault/keyvault-certificates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/fs-extra": "^8.0.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/query-string": "6.2.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
Expand Down Expand Up @@ -135,7 +135,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
4 changes: 2 additions & 2 deletions sdk/keyvault/keyvault-keys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/fs-extra": "^8.0.0",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/query-string": "6.2.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
Expand Down Expand Up @@ -132,7 +132,7 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"mocha": "^6.2.2",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
Expand Down
6 changes: 4 additions & 2 deletions sdk/keyvault/keyvault-keys/test/crypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
});

afterEach(async function() {
await testClient.flushKey(keyName);
recorder.stop();
if (!this.currentTest?.isPending()) {
await testClient.flushKey(keyName);
recorder.stop();
}
});

// The tests follow
Expand Down

0 comments on commit b659e18

Please sign in to comment.