Add sample tests for LUIS runtime package (#3317)
* Add sample tests for LUIS runtime package * Update version * Move test script to build * Add npm run test as part of codegen process * Add missing await
This commit is contained in:
Родитель
1e2c407392
Коммит
4d25a49a9e
|
@ -57,6 +57,15 @@ export function npmInstall(packageFolderPath: string): void {
|
|||
execute("npm install", packageFolderPath);
|
||||
}
|
||||
|
||||
export async function npmRunTest(packageFolderPath: string): Promise<void> {
|
||||
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<string[]> {
|
||||
const allChildren = await fs.readdir(parent);
|
||||
const childDirectories = [];
|
||||
|
|
|
@ -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:');
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
const equal = require('assert');
|
||||
|
||||
describe("Sample", function() {
|
||||
it("should always pass", function() {
|
||||
equal([1, 2, 3].indexOf(3), -1);
|
||||
});
|
||||
});
|
Загрузка…
Ссылка в новой задаче