Skip to content

Commit

Permalink
DigitalTwins: Add E2E tests (Azure#13135)
Browse files Browse the repository at this point in the history
* feat(azure-digitaltwins): update swagger

* feat(azure-digitaltwins): update client to swagger

* chore(azure-digitaltwins-core): rename package

* chore(azure-digitaltwins-core): rename package

* feat(azure-digital-twins-core): add span

* feat(azure-digital-twins-core): update for GA

* chore(azure-digital-twins-core): fix readme

* Update Readme.md

* chore(azure-digital-twins-core): fix exports

* chore(azure-digital-twins-core): fix broken links

* chore(azure-digital-twins-core): update changelog

* chore(azure-digital-twins-core): comment changelog

* chore(azure-digital-twins-core): more comment

* Update CHANGELOG.md

* fix(azure-digital-twins-core): address feedbacks

* fix(azure-digital-twins-core): add ifmatch

* fix(azure-digital-twins-core): add ifMatch

* fix(digitaltwins): hide ifmatch to options

* chore(digitaltwin): autofix

* fix(digitaltwins): fix export warnings

* fix(digitaltwins): fix diagnostic namespace

* fix(digitaltwins): improve tracing

* chore(digitaltwins): autofix

* fix(digitaltwins: fix tracing

* chore(digitaltwins): autofix

* fix(digitaltwins): delete parameter grouping

* chore(digitaltwins): autofix

* chore(digitaltwins): clean up

* Add E2E tests

* Add E2E tests

* Update recordings

* Remove comments

* --harmony flag for async iterators

* Update CHANGELOG.md

* Update version in package.json

Co-authored-by: Jeff Fisher <[email protected]>
Co-authored-by: HarshaNalluru <[email protected]>
  • Loading branch information
3 people authored and ljian3377 committed Jan 22, 2021
1 parent d72882a commit 2f9e67a
Show file tree
Hide file tree
Showing 186 changed files with 29,345 additions and 62 deletions.
7 changes: 7 additions & 0 deletions sdk/digitaltwins/digital-twins-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release History

## 1.0.1 (2021-01-12)

- This release is an update the GA release containing the following changes:
- Fix publishComponentTelemetry API to follow the convention, now messageId is a mandatory argument
- Add E2E live and record/playback tests
- Add samples of delete digitaltwins and models for convenience

## 1.0.0 (2020-10-30)

- The is the GA release containing the following changes:
Expand Down
31 changes: 25 additions & 6 deletions sdk/digitaltwins/digital-twins-core/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config();
const {
jsonRecordingFilterFunction,
isPlaybackMode,
isSoftRecordMode,
isRecordMode
} = require("@azure/test-utils-recorder");

module.exports = function(config) {
config.set({
Expand All @@ -21,7 +27,9 @@ module.exports = function(config) {
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-junit-reporter"
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-json-preprocessor"
],

// list of files / patterns to load in the browser
Expand All @@ -31,25 +39,27 @@ module.exports = function(config) {
"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",
"test-browser/index.js",
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: true }
],
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),

// list of files / patterns to exclude
exclude: [],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["env"]
"**/*.js": ["env"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
// "test-browser/index.js": ["coverage"]
"dist-test/index.browser.js": ["coverage"],
"recordings/browsers/**/*.json": ["json"]
},

// inject following environment values into browser testing with window.__env__
// environment values MUST be exported or set with same console running "karma start"
// https://www.npmjs.com/package/karma-env-preprocessor
envPreprocessor: [
"AZ_CONFIG_CONNECTION",
"AZURE_DIGITALTWINS_URL",
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_ID",
Expand All @@ -59,7 +69,7 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit"],
reporters: ["mocha", "coverage", "junit", "json-to-file", "karma-remap-istanbul"],

coverageReporter: {
// specify a common output directory
Expand Down Expand Up @@ -87,6 +97,12 @@ module.exports = function(config) {
properties: {} // key value pair of properties to add to the <properties> section of the report
},

jsonToFileReporter: {
// required - to save the recordings of browser tests
filter: jsonRecordingFilterFunction,
outputPath: "."
},

// web server port
port: 9876,

Expand All @@ -108,7 +124,7 @@ module.exports = function(config) {
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: "ChromeHeadless",
flags: ["--no-sandbox"]
flags: ["--no-sandbox", "--disable-web-security"]
}
},

Expand All @@ -123,6 +139,9 @@ module.exports = function(config) {
browserNoActivityTimeout: 600000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
browserConsoleLogOptions: {
terminal: !isRecordMode()
},

client: {
mocha: {
Expand Down
6 changes: 3 additions & 3 deletions sdk/digitaltwins/digital-twins-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/digital-twins-core",
"version": "1.0.0",
"version": "1.0.1",
"description": "An isomorphic client library for Azure Digital Twins",
"sdk-type": "client",
"author": "Microsoft Corporation",
Expand Down Expand Up @@ -28,7 +28,7 @@
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "npm run build:test:browser && cross-env TEST_MODE=live karma start --single-run",
"integration-test:node": "npm run build:test:node && nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace dist-esm/test/*.spec.js dist-esm/test/**/*.spec.js",
"integration-test:node": "npm run build:test:node && nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace dist-esm/test/*.spec.js dist-esm/test/**/*.spec.js --harmony",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o search-lintReport.html || exit 0",
Expand All @@ -38,7 +38,7 @@
"test:browser": "npm run clean && npm run build:test:browser && npm run unit-test:browser",
"test": "npm run clean && npm run build:test && npm run unit-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace dist-test/index.node.js",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace dist-test/index.node.js --harmony",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --mode file --out ./dist/docs ./src"
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2f9e67a

Please sign in to comment.