diff --git a/.scripts/common.ts b/.scripts/common.ts index 10259f540d1..db27633cc2d 100644 --- a/.scripts/common.ts +++ b/.scripts/common.ts @@ -57,6 +57,15 @@ export function npmInstall(packageFolderPath: string): void { execute("npm install", packageFolderPath); } +export async function npmRunTest(packageFolderPath: string): Promise { + const packageJsonContent = JSON.parse((await fs.readFile(path.join(packageFolderPath, "package.json"))).toString()); + if (packageJsonContent.scripts.test) { + execute("npm test", packageFolderPath); + } else { + console.log("No tests to run"); + } +} + export async function getChildDirectories(parent: string): Promise { const allChildren = await fs.readdir(parent); const childDirectories = []; diff --git a/.scripts/gulp.ts b/.scripts/gulp.ts index fd81192b3b2..9ede4754c62 100644 --- a/.scripts/gulp.ts +++ b/.scripts/gulp.ts @@ -7,7 +7,7 @@ import { execSync } from "child_process"; import fs from "fs"; import * as path from "path"; -import { contains, npmInstall } from "./common"; +import { contains, npmInstall, npmRunTest } from "./common"; import { Logger } from "./logger"; import { getPackageInformationFromPackageJsons, PackageInfo } from "./packages"; import { findReadmeTypeScriptMdFilePaths, getAbsolutePackageFolderPathFromReadmeFileContents, getPackageNamesFromReadmeTypeScriptMdFileContents } from "./readme"; @@ -71,7 +71,8 @@ export async function generateSdk(azureRestAPISpecsRoot: string, azureSDKForJSRe _logger.log('Error:'); _logger.log(`Could not determine the generated package folder's path from ${typeScriptReadmeFilePath}.`); } else { - npmInstall(packageFolderPath); + await npmInstall(packageFolderPath); + await npmRunTest(packageFolderPath); } } catch (err) { _logger.log('Error:'); diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md b/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md index c4793bb2fb4..daf450ed101 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md @@ -144,3 +144,5 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to ## Related projects - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/package.json b/sdk/cognitiveservices/cognitiveservices-luis-runtime/package.json index c6db938b671..a58eadb7b9f 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-runtime/package.json +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/package.json @@ -2,7 +2,7 @@ "name": "@azure/cognitiveservices-luis-runtime", "author": "Microsoft Corporation", "description": "LUISRuntimeClient Library with typescript type definitions for node.js and browser.", - "version": "3.0.0", + "version": "3.0.1", "dependencies": { "@azure/ms-rest-js": "^1.8.1", "tslib": "^1.9.3" @@ -23,15 +23,17 @@ "rollup": "^0.66.2", "rollup-plugin-node-resolve": "^3.4.0", "rollup-plugin-sourcemaps": "^0.4.2", - "uglify-js": "^3.4.9" + "uglify-js": "^3.4.9", + "mocha": "^6.1.4", + "nock": "^10.0.0" }, - "homepage": "https://github.com/azure/azure-sdk-for-js", + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-luis-runtime", "repository": { "type": "git", - "url": "https://github.com/azure/azure-sdk-for-js.git" + "url": "https://github.com/Azure/azure-sdk-for-js.git" }, "bugs": { - "url": "https://github.com/azure/azure-sdk-for-js/issues" + "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, "files": [ "dist/**/*.js", @@ -50,7 +52,8 @@ "scripts": { "build": "tsc && rollup -c rollup.config.js && npm run minify", "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-luis-runtime.js.map'\" -o ./dist/cognitiveservices-luis-runtime.min.js ./dist/cognitiveservices-luis-runtime.js", - "prepack": "npm install && npm run build" + "prepack": "npm install && npm run build && npm run test", + "test": "mocha" }, "sideEffects": false, "autoPublish": true diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/src/lUISRuntimeClientContext.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/src/lUISRuntimeClientContext.ts index 841023dc7a9..42eea0a9198 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-runtime/src/lUISRuntimeClientContext.ts +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/src/lUISRuntimeClientContext.ts @@ -11,7 +11,7 @@ import * as msRest from "@azure/ms-rest-js"; const packageName = "@azure/cognitiveservices-luis-runtime"; -const packageVersion = "3.0.0"; +const packageVersion = "3.0.1"; export class LUISRuntimeClientContext extends msRest.ServiceClient { endpoint: string; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/test/test.js b/sdk/cognitiveservices/cognitiveservices-luis-runtime/test/test.js new file mode 100644 index 00000000000..2fefe3719e0 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/test/test.js @@ -0,0 +1,7 @@ +const equal = require('assert'); + +describe("Sample", function() { + it("should always pass", function() { + equal([1, 2, 3].indexOf(3), -1); + }); +});