Skip to content

Commit

Permalink
[KeyVault-Certificates] Rollup and test utils (#4749)
Browse files Browse the repository at this point in the history
* [KeyVault-Certificates] Rollup and test utils

Related to #4623 and #4624
  • Loading branch information
sadasant authored Aug 14, 2019
1 parent c303d91 commit e91dd1c
Show file tree
Hide file tree
Showing 16 changed files with 1,827 additions and 121 deletions.
128 changes: 128 additions & 0 deletions sdk/keyvault/keyvault-certificates/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config({ path: "../.env" });

module.exports = function(config) {
config.set({
basePath: "./",
frameworks: ["mocha"],

plugins: [
"karma-mocha",
"karma-mocha-reporter",
"karma-chrome-launcher",
"karma-edge-launcher",
"karma-firefox-launcher",
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-coverage",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-json-preprocessor"
],

files: [
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js",
"recordings/browsers/**/*.json"
],

exclude: [],

preprocessors: {
"**/*.js": ["env"],
"dist-test/index.browser.js": ["coverage"],
"recordings/browsers/**/*.json": ["json"]
},

envPreprocessor: [
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_ID",
"KEYVAULT_NAME",
"TEST_MODE"
],

reporters: ["mocha", "coverage", "remap-coverage", "junit", "json-to-file"],

coverageReporter: { type: "in-memory" },

remapCoverageReporter: {
"text-summary": null,
html: "./coverage-browser",
cobertura: "./coverage-browser/cobertura-coverage.xml"
},

remapOptions: {
exclude: /node_modules|tests/g
},

junitReporter: {
outputDir: "",
outputFile: "test-results.browser.xml",
suite: "",
useBrowserName: false,
nameFormatter: undefined,
classNameFormatter: undefined,
properties: {}
},

jsonToFileReporter: {
filter: function(obj) {
if (obj.writeFile) {
const fs = require("fs-extra");
try {
// Stripping away the filename from the file path and retaining the directory structure
fs.ensureDirSync(obj.path.substring(0, obj.path.lastIndexOf("/") + 1));
} catch (err) {
if (err.code !== "EEXIST") throw err;
}
fs.writeFile(obj.path, JSON.stringify(obj.content, null, " "), (err) => {
if (err) {
throw err;
}
});
}
return false;
},
outputPath: "."
},

port: 9328,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,

// --no-sandbox allows our tests to run in Linux without having to change the system.
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
browsers: ["ChromeHeadlessNoSandbox"],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: "ChromeHeadless",
flags: ["--no-sandbox", "--disable-web-security"]
}
},

singleRun: false,
concurrency: 1,

browserNoActivityTimeout: 600000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
browserConsoleLogOptions: {
// IMPORTANT: COMMENT the following line if you want to print debug logs in your browsers in record mode!!
terminal: process.env.TEST_MODE !== "record"
},

client: {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: "html",
timeout: "600000"
}
}
});
};
57 changes: 49 additions & 8 deletions sdk/keyvault/keyvault-certificates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,51 +47,92 @@
"build:samples": "tsc samples/helloWorld.ts",
"build:es6": "tsc -p tsconfig.json",
"build:nodebrowser": "rollup -c 2>&1",
"build:test": "echo skipped",
"build:test": "npm run build:es6 && rollup -c rollup.test.config.js 2>&1",
"build": "npm run extract-api && npm run build:samples && npm run build:es6 && npm run build:nodebrowser",
"check-format": "prettier --list-different --config ../../.prettierrc.json \"src/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist esm test-dist typings *.tgz *.log",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha --require source-map-support/register --reporter mocha-multi --timeout 1200000 --reporter-options spec=-,mocha-junit-reporter=- --full-trace dist-test/index.node.js",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint \"src/**/*.ts\" -c ../../.eslintrc.json --fix --fix-type [problem,suggestion]",
"lint": "eslint -c ../../.eslintrc.json src --ext .ts -f html -o keyvault-certificates-lintReport.html || exit 0",
"lint": "eslint -c ../../.eslintrc.json src tests samples --ext .ts -f html -o keyvault-certificates-lintReport.html || exit 0",
"lint:terminal": "eslint -c ../../.eslintrc.json src tests samples --ext .ts",
"pack": "npm pack 2>&1",
"prebuild": "npm run clean",
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
"test": "npm run build:test && npm run unit-test && npm run integration-test",
"unit-test:browser": "echo skipped",
"unit-test:node": "echo skipped",
"unit-test:browser": "cross-env TEST_MODE=playback npm run integration-test:browser",
"unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node",
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
},
"sideEffects": false,
"dependencies": {
"@azure/core-paging": "1.0.0-preview.1",
"@azure/core-arm": "1.0.0-preview.2",
"@azure/core-http": "1.0.0-preview.2",
"@azure/core-paging": "1.0.0-preview.1",
"@azure/core-tracing": "1.0.0-preview.1",
"@azure/identity": "1.0.0-preview.2",
"tslib": "^1.9.3"
},
"devDependencies": {
"@azure/identity": "1.0.0-preview.2",
"@microsoft/api-extractor": "^7.1.5",
"@types/chai": "^4.1.6",
"@types/dotenv": "^6.1.0",
"@types/fs-extra": "^8.0.0",
"@types/mocha": "^5.2.5",
"@types/nise": "^1.4.0",
"@types/nock": "^10.0.1",
"@types/node": "^8.0.0",
"@types/query-string": "6.2.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"assert": "^1.4.1",
"chai": "^4.2.0",
"cross-env": "^5.2.0",
"dotenv": "^8.0.0",
"eslint": "^6.1.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-no-only-tests": "^2.3.0",
"eslint-plugin-promise": "^4.1.1",
"fs-extra": "^8.1.0",
"karma": "^4.0.1",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^1.1.2",
"karma-edge-launcher": "^0.4.2",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-json-preprocessor": "^0.3.3",
"karma-json-to-file-reporter": "^1.0.1",
"karma-junit-reporter": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-coverage": "^0.1.5",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.18.0",
"mocha-multi": "^1.0.1",
"nise": "^1.4.10",
"nock": "^10.0.6",
"nyc": "^14.0.0",
"prettier": "^1.16.4",
"puppeteer": "^1.11.0",
"query-string": "^5.0.0",
"rimraf": "^2.6.2",
"rollup": "^1.16.3",
"rollup": "^1.16.3",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-resolve": "^5.0.2",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^2.0.0",
"source-map-support": "^0.5.9",
"typescript": "^3.2.2",
"uglify-js": "^3.4.9",
"url": "^0.11.0"
Expand Down
Loading

0 comments on commit e91dd1c

Please sign in to comment.