OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[OV JS] npm run lint on .js files (#26543)
Alicja Miloszewskab4af3d53291a
diff --git a/src/bindings/js/.eslintrc-global.js b/src/bindings/js/.eslintrc-global.jsindex 623b8ba549a..7f4abc54561 100644--- a/src/bindings/js/.eslintrc-global.js+++ b/src/bindings/js/.eslintrc-global.js@@ -2,7 +2,7 @@ module.exports = {rules: {'semi': ['error'],'no-var': ['error'],- 'max-len': ['error'],+ 'max-len': ['error', { 'ignoreUrls': true }],'eol-last': ['error'],'indent': ['error', 2],'camelcase': ['error'],@@ -23,5 +23,6 @@ module.exports = {'key-spacing': ['error', { beforeColon: false }],'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],'keyword-spacing': ['error', { overrides: { catch: { after: false } } }],+ '@typescript-eslint/no-var-requires': 0,}};diff --git a/src/bindings/js/.eslintrc.js b/src/bindings/js/.eslintrc.jsindex 8cb6464d27d..5958104aa92 100644--- a/src/bindings/js/.eslintrc.js+++ b/src/bindings/js/.eslintrc.js@@ -4,6 +4,6 @@ module.exports = {'plugin:@typescript-eslint/recommended','./.eslintrc-global.js',],- ignorePatterns: ['**/*.js', 'node_modules/', 'types/', 'dist/', 'bin/'],+ ignorePatterns: ['node_modules/', 'types/', 'dist/', 'bin/', '.eslintrc.js'],root: true,};diff --git a/src/bindings/js/node/.eslintrc.js b/src/bindings/js/node/.eslintrc.jsindex 992f409c909..24ba06e7821 100644--- a/src/bindings/js/node/.eslintrc.js+++ b/src/bindings/js/node/.eslintrc.js@@ -1,5 +1,8 @@module.exports = {extends: ['../.eslintrc.js'],+ env: {+ node: true,+ },parser: '@typescript-eslint/parser',plugins: ['@typescript-eslint'],};diff --git a/src/bindings/js/node/lib/addon.ts b/src/bindings/js/node/lib/addon.tsindex c2ba1d9c61f..060af2cfec9 100644--- a/src/bindings/js/node/lib/addon.ts+++ b/src/bindings/js/node/lib/addon.ts@@ -48,7 +48,7 @@ interface Core {compileModel(model: Model,deviceName: string,- config?: { [propertyName: string]: string }+ config?: { [propertyName: string]: string },): Promise<CompiledModel>;/*** Asynchronously reads a model and creates a compiled model@@ -67,7 +67,7 @@ interface Core {compileModel(modelPath: string,deviceName: string,- config?: { [propertyName: string]: string }+ config?: { [propertyName: string]: string },): Promise<CompiledModel>;/*** A synchronous version of {@link Core.compileModel}.@@ -76,7 +76,7 @@ interface Core {compileModelSync(model: Model,deviceName: string,- config?: { [propertyName: string]: string }+ config?: { [propertyName: string]: string },): CompiledModel;/*** A synchronous version of {@link Core.compileModel}.@@ -85,7 +85,7 @@ interface Core {compileModelSync(modelPath: string,deviceName: string,- config?: { [propertyName: string]: string }+ config?: { [propertyName: string]: string },): CompiledModel;/*** It returns a list of available inference devices.@@ -118,9 +118,9 @@ interface Core {*/getVersions(deviceName: string): {[deviceName: string]: {- buildNumber: string,- description: string,- },+ buildNumber: string;+ description: string;+ };};/*** Asynchronously imports a previously exported compiled model.@@ -135,7 +135,7 @@ interface Core {importModel(modelStream: Buffer,device: string,- config?: { [key: string]: string | number | boolean }+ config?: { [key: string]: string | number | boolean },): Promise<CompiledModel>;/*** A synchronous version of {@link Core.importModel}.@@ -144,7 +144,7 @@ interface Core {importModelSync(modelStream: Buffer,device: string,- config?: { [key: string]: string | number | boolean }+ config?: { [key: string]: string | number | boolean },): CompiledModel;/*** It reads models from the IR / ONNX / PDPD / TF and TFLite formats.@@ -175,7 +175,9 @@ interface Core {* @param weightsBuffer Binary data with tensor data.*/readModel(- modelBuffer: Uint8Array, weightsBuffer?: Uint8Array): Promise<Model>;+ modelBuffer: Uint8Array,+ weightsBuffer?: Uint8Array,+ ): Promise<Model>;/*** A synchronous version of {@link Core.readModel}.* It reads models from the IR / ONNX / PDPD / TF and TFLite formats.@@ -220,7 +222,7 @@ interface Core {): {[key: string]: string | number | boolean};}interface CoreConstructor {- new(): Core;+ new (): Core;}/**@@ -277,9 +279,9 @@ interface Model {*/isDynamic(): boolean;/**- * It gets the output of the model.- * If a model has more than one output, this method throws an exception.- */+ * It gets the output of the model.+ * If a model has more than one output, this method throws an exception.+ */output(): Output;/*** It gets the output of the model identified by the tensor name.@@ -372,15 +374,15 @@ interface CompiledModel {* @returns {Output} A compiled model input.*/input(name: string): Output;- /**+ /*** It sets properties for the current compiled model. Properties* can be retrieved via {@link CompiledModel.getProperty}.* @param property An object with the key-value pairs.* (property name, property value)*/- setProperty(properties: {- [propertyName: string]: string | number | boolean- }): void;+ setProperty(properties: {+ [propertyName: string]: string | number | boolean;+ }): void;}/**@@ -438,7 +440,7 @@ interface TensorConstructor {* @param type The element type of the new tensor.* @param shape The shape of the new tensor.*/- new(type: element | elementTypeString, shape: number[]): Tensor;+ new (type: element | elementTypeString, shape: number[]): Tensor;/*** It constructs a tensor using the element type and shape. The new tensor* wraps allocated host memory.@@ -447,14 +449,17 @@ interface TensorConstructor {* @param tensorData A subclass of TypedArray that will be wrapped* by a {@link Tensor}.*/- new(type: element | elementTypeString, shape: number[],- tensorData: SupportedTypedArray): Tensor;+ new (+ type: element | elementTypeString,+ shape: number[],+ tensorData: SupportedTypedArray,+ ): Tensor;/*** It constructs a tensor using the element type and shape. The strings from* the array are used to fill the new tensor. Each element of a string tensor* is a string of arbitrary length, including an empty string.*/- new(tensorData: string[]): Tensor;+ new (tensorData: string[]): Tensor;}/**@@ -478,8 +483,9 @@ interface InferRequest {* TypedArray will be wrapped into Tensor underneath using the input shape* and element type of the deployed model.*/- infer(inputData: { [inputName: string]: Tensor | SupportedTypedArray })- : { [outputName: string]: Tensor };+ infer(inputData: { [inputName: string]: Tensor | SupportedTypedArray }): {+ [outputName: string]: Tensor;+ };/*** It infers specified input(s) in the synchronous mode.* @param inputData An array with tensors or TypedArrays. TypedArrays will be@@ -487,16 +493,18 @@ interface InferRequest {* of the deployed model. If the model has multiple inputs, the Tensors* and TypedArrays must be passed in the correct order.*/- infer(inputData: Tensor[] | SupportedTypedArray[])- : { [outputName: string]: Tensor };+ infer(inputData: Tensor[] | SupportedTypedArray[]): {+ [outputName: string]: Tensor;+ };/*** It infers specified input(s) in the asynchronous mode.* @param inputData An object with the key-value pairs where the key is the* input name and value is a tensor or an array with tensors. If the model has* multiple inputs, the Tensors must be passed in the correct order.*/- inferAsync(inputData: { [inputName: string]: Tensor }- | Tensor[]): Promise<{ [outputName: string]: Tensor }>;+ inferAsync(+ inputData: { [inputName: string]: Tensor } | Tensor[],+ ): Promise<{ [outputName: string]: Tensor }>;/*** It gets the compiled model used by the InferRequest object.*/@@ -521,11 +529,11 @@ interface InferRequest {*/getOutputTensor(): Tensor;/**- * It gets the output tensor for inference.- * @param idx An index of the tensor to get.- * @returns A tensor at the specified index. If the tensor with the specified- * idx is not found, an exception is thrown.- */+ * It gets the output tensor for inference.+ * @param idx An index of the tensor to get.+ * @returns A tensor at the specified index. If the tensor with the specified+ * idx is not found, an exception is thrown.+ */getOutputTensor(idx?: number): Tensor;/*** It gets an input/output tensor for inference.@@ -619,7 +627,7 @@ interface PrePostProcessor {output(idxOrTensorName?: number | string): OutputInfo;}interface PrePostProcessorConstructor {- new(model: Model): PrePostProcessor;+ new (model: Model): PrePostProcessor;}interface PartialShape {@@ -638,7 +646,7 @@ interface PartialShapeConstructor {* Omit parameter to create empty shape.* @param [shape] String representation of the shape.*/- new(shape?: string): PartialShape;+ new (shape?: string): PartialShape;}declare enum element {@@ -662,18 +670,16 @@ declare enum resizeAlgorithm {}export interface NodeAddon {- Core: CoreConstructor,- Tensor: TensorConstructor,- PartialShape: PartialShapeConstructor,+ Core: CoreConstructor;+ Tensor: TensorConstructor;+ PartialShape: PartialShapeConstructor;preprocess: {- resizeAlgorithm: typeof resizeAlgorithm,- PrePostProcessor: PrePostProcessorConstructor,- },- element: typeof element,+ resizeAlgorithm: typeof resizeAlgorithm;+ PrePostProcessor: PrePostProcessorConstructor;+ };+ element: typeof element;}-export default- // eslint-disable-next-line @typescript-eslint/no-var-requires- require('../bin/ov_node_addon.node') as- NodeAddon;+export default // eslint-disable-next-line @typescript-eslint/no-var-requires+require('../bin/ov_node_addon.node') as NodeAddon;diff --git a/src/bindings/js/node/scripts/download_runtime.js b/src/bindings/js/node/scripts/download_runtime.jsindex 775b4aa6c75..321eb4b125b 100644--- a/src/bindings/js/node/scripts/download_runtime.js+++ b/src/bindings/js/node/scripts/download_runtime.js@@ -25,10 +25,11 @@ async function main() {try {await downloadRuntime(destinationPath, { force, ignoreIfExists, proxy });- } catch (error) {+ } catch(error) {if (error instanceof RuntimeExistsError) {console.error(- `Directory '${destinationPath}' already exists. To force runtime downloading run 'npm run download_runtime -- -f'`+ `Directory '${destinationPath}' already exists. ` ++ 'To force runtime downloading run \'npm run download_runtime -- -f\'',);} else {throw error;@@ -52,13 +53,18 @@ class RuntimeExistsError extends Error {* @function downloadRuntime* @param {string} destinationPath - The destination directory path.* @param {Object} [config] - The configuration object.- * @param {boolean} [config.force=false] - The flag to force install and replace runtime if it exists. Default is `false`.- * @param {boolean} [config.ignoreIfExists=true] - The flag to skip installation if it exists Default is `true`.+ * @param {boolean} [config.force=false] - The flag+ * to force install and replace runtime if it exists. Default is `false`.+ * @param {boolean} [config.ignoreIfExists=true] - The flag+ * to skip installation if it exists Default is `true`.* @param {string|null} [config.proxy=null] - The proxy URL. Default is `null`.* @returns {Promise<void>}* @throws {RuntimeExistsError}*/-async function downloadRuntime(destinationPath, config = { force: false, ignoreIfExists: true, proxy: null }) {+async function downloadRuntime(+ destinationPath,+ config = { force: false, ignoreIfExists: true, proxy: null },+) {const { version } = packageJson;const osInfo = await getOsInfo();const isRuntimeDirectoryExists = await checkIfPathExists(destinationPath);@@ -66,13 +72,16 @@ async function downloadRuntime(destinationPath, config = { force: false, ignoreIif (isRuntimeDirectoryExists && !config.force) {if (config.ignoreIfExists) {console.warn(- `Directory '${destinationPath}' already exists. Skipping runtime downloading because 'ignoreIfExists' flag is passed.`+ `Directory '${destinationPath}' already exists. Skipping ` ++ 'runtime downloading because \'ignoreIfExists\' flag is passed.',);+return;}throw new RuntimeExistsError(- `Directory '${destinationPath}' already exists. To force runtime downloading use 'force' flag.`+ `Directory '${destinationPath}' already exists. ` ++ 'To force runtime downloading use \'force\' flag.',);}@@ -87,7 +96,12 @@ async function downloadRuntime(destinationPath, config = { force: false, ignoreIawait fs.mkdir(tempDirectoryPath);console.log('Downloading OpenVINO runtime archive...');- await downloadFile(runtimeArchiveUrl, tempDirectoryPath, filename, config.proxy);+ await downloadFile(+ runtimeArchiveUrl,+ tempDirectoryPath,+ filename,+ config.proxy,+ );console.log('OpenVINO runtime archive downloaded.');await removeDirectory(destinationPath);@@ -96,7 +110,7 @@ async function downloadRuntime(destinationPath, config = { force: false, ignoreIawait unarchive(archiveFilePath, destinationPath);console.log('The archive was successfully extracted.');- } catch (error) {+ } catch(error) {console.error(`Failed to download OpenVINO runtime: ${error}.`);throw error;} finally {@@ -149,8 +163,9 @@ async function getOsInfo() {async function checkIfPathExists(path) {try {await fs.access(path);+return true;- } catch (error) {+ } catch(error) {if (error.code === codeENOENT) {return false;}@@ -167,12 +182,12 @@ async function checkIfPathExists(path) {* @returns {string}*/function getRuntimeArchiveUrl(version, osInfo) {- const {+ const {host,package_name: packageNameTemplate,remote_path: remotePathTemplate,} = packageJson.binary;- const fullPathTemplate = `${remotePathTemplate}${packageNameTemplate}`+ const fullPathTemplate = `${remotePathTemplate}${packageNameTemplate}`;const fullPath = fullPathTemplate.replace(new RegExp('{version}', 'g'), version).replace(new RegExp('{platform}', 'g'), osInfo.platform)@@ -193,7 +208,7 @@ async function removeDirectory(path) {try {console.log(`Removing ${path}`);await fs.rm(path, { recursive: true, force: true });- } catch (error) {+ } catch(error) {if (error.code === codeENOENT) console.log(`Path: ${path} doesn't exist`);throw error;@@ -215,7 +230,7 @@ function downloadFile(url, destination, filename, proxy = null) {const fullPath = path.resolve(destination, filename);const file = createWriteStream(fullPath);- if (new URL(url).protocol === 'http')+ if (new URL(url).protocol === 'http')throw new Error('Http link doesn\'t support');let agent;@@ -271,12 +286,15 @@ function unarchive(tarFilePath, dest) {return new Promise((resolve, reject) => {createReadStream(tarFilePath).pipe(gunzip())- .pipe(tar.extract(dest)- .on('finish', () => {- resolve();- }).on('error', (err) => {- reject(err);- }),+ .pipe(+ tar+ .extract(dest)+ .on('finish', () => {+ resolve();+ })+ .on('error', (err) => {+ reject(err);+ }),);});}diff --git a/src/bindings/js/node/tests/e2e/demo-electron-app/index.js b/src/bindings/js/node/tests/e2e/demo-electron-app/index.jsindex 9f5fcb8511b..cfa5fd27b0f 100644--- a/src/bindings/js/node/tests/e2e/demo-electron-app/index.js+++ b/src/bindings/js/node/tests/e2e/demo-electron-app/index.js@@ -3,6 +3,7 @@ const { addon: ov } = require('openvino-node');app.whenReady().then(() => {console.log('Creating OpenVINO Runtime Core');+ // eslint-disable-next-line @typescript-eslint/no-unused-varsconst core = new ov.Core();console.log('Created OpenVINO Runtime Core');diff --git a/src/bindings/js/node/tests/e2e/electron-app.test.js b/src/bindings/js/node/tests/e2e/electron-app.test.jsindex 948146b9822..01e84dea884 100644--- a/src/bindings/js/node/tests/e2e/electron-app.test.js+++ b/src/bindings/js/node/tests/e2e/electron-app.test.js@@ -1,29 +1,36 @@+/* global describe, it, before, after */const fs = require('node:fs');const assert = require('node:assert');const { exec } = require('child_process');-describe('E2E test of installation openvino as electron dependency', function() {+describe('E2E testing for OpenVINO as an Electron dependency.', function() {this.timeout(50000);before((done) => {- exec('cp -r ./tests/e2e/demo-electron-app/ demo-electron-app-project', (error) => {- if (error) {- console.error(`exec error: ${error}`);+ exec(+ 'cp -r ./tests/e2e/demo-electron-app/ demo-electron-app-project',+ (error) => {+ if (error) {+ console.error(`exec error: ${error}`);- return done(error);- }+ return done(error);+ }- done();- });+ done();+ },+ );});it('should install dependencies', (done) => {exec('cd demo-electron-app-project && npm install', (error) => {if (error) {console.error(`exec error: ${error}`);+return done(error);}- const packageJson = JSON.parse(fs.readFileSync('demo-electron-app-project/package-lock.json', 'utf8'));+ const packageJson = JSON.parse(+ fs.readFileSync('demo-electron-app-project/package-lock.json', 'utf8'),+ );assert.equal(packageJson.name, 'demo-electron-app');done();});diff --git a/src/bindings/js/node/tests/unit/basic.test.js b/src/bindings/js/node/tests/unit/basic.test.jsindex d84aabeb912..0717b430ae0 100644--- a/src/bindings/js/node/tests/unit/basic.test.js+++ b/src/bindings/js/node/tests/unit/basic.test.js@@ -9,8 +9,7 @@ const { testModels, getModelPath, isModelAvailable } = require('./utils.js');const epsilon = 0.5;describe('ov basic tests.', () => {-- let testXml = null;+ let testXml = null;let core = null;let model = null;let compiledModel = null;@@ -35,7 +34,6 @@ describe('ov basic tests.', () => {});describe('Core.getVersions()', () => {-it('getVersions(validDeviceName: string)', () => {const deviceVersion = core.getVersions('CPU');assert.strictEqual(typeof deviceVersion, 'object');@@ -44,20 +42,15 @@ describe('ov basic tests.', () => {assert.strictEqual(typeof deviceVersion.CPU.description, 'string');});- it('getVersions() throws if no arguments are passed into the function', () => {- assert.throws(- () => core.getVersions(),- { message: 'getVersions() method expects 1 argument of string type.' }- );+ it('getVersions() throws if no arguments are passed', () => {+ assert.throws(() => core.getVersions(), {+ message: 'getVersions() method expects 1 argument of string type.',+ });});- it('getVersions() throws if non string coercable arguments are passed into the function', () => {- assert.throws(- () => core.getVersions({ deviceName: 'CPU' }),- { message: 'The argument in getVersions() method must be a string or convertible to a string.' }- );+ it('getVersions() throws with non string coercable arg.', () => {+ assert.throws(() => core.getVersions({ deviceName: 'CPU' }));});-});it('CompiledModel type', () => {@@ -70,14 +63,14 @@ describe('ov basic tests.', () => {});describe('Core.compileModelSync()', () => {- const tput = { 'PERFORMANCE_HINT': 'THROUGHPUT' };+ const tput = { PERFORMANCE_HINT: 'THROUGHPUT' };it('compileModelSync(model:Model, deviceName: string, config: {}) ', () => {const cm = core.compileModelSync(model, 'CPU', tput);assert.deepStrictEqual(cm.output(0).shape, [1, 10]);});- it('compileModelSync(model:model_path, deviceName: string, config: {}) ', () => {+ it('compileModelSync(model_path, deviceName, config: {}) ', () => {const cm = core.compileModelSync(testXml, 'CPU', tput);assert.equal(cm.inputs.length, 1);});@@ -87,14 +80,16 @@ describe('ov basic tests.', () => {assert.deepStrictEqual(cm.output(0).shape, [1, 10]);});- it('compileModelSync(model, device, config) throws when config is a string', () => {- const expectedMsg = ('\'compileModelSync\' method called with incorrect parameters.\n' +- 'Provided signature: (object, string, string) \n' +- 'Allowed signatures:\n' +- '- (string, string)\n' +- '- (Model, string)\n' +- '- (string, string, object)\n' +- '- (Model, string, object)\n').replace(/[()]/g, '\\$&');+ it('compileModelSync(model, device, configOfTypeString) throws', () => {+ const expectedMsg = (+ '\'compileModelSync\' method called with incorrect parameters.\n' ++ 'Provided signature: (object, string, string) \n' ++ 'Allowed signatures:\n' ++ '- (string, string)\n' ++ '- (Model, string)\n' ++ '- (string, string, object)\n' ++ '- (Model, string, object)\n'+ ).replace(/[()]/g, '\\$&');assert.throws(() => core.compileModelSync(model, 'CPU', 'string'),@@ -102,21 +97,23 @@ describe('ov basic tests.', () => {);});- it('compileModelSync(model, device, config) throws when config value is not a string', () => {+ it('compileModelSync(model, device, invalidConfig) throws', () => {assert.throws(- () => core.compileModelSync(model, 'CPU', { 'PERFORMANCE_HINT': tput }),- /Cannot convert to ov::Any/+ () => core.compileModelSync(model, 'CPU', { PERFORMANCE_HINT: tput }),+ /Cannot convert to ov::Any/,);});- it('compileModelSync(model) throws if the number of arguments is invalid', () => {- const expectedMsg = ('\'compileModelSync\' method called with incorrect parameters.\n' +- 'Provided signature: (object) \n' +- 'Allowed signatures:\n' +- '- (string, string)\n' +- '- (Model, string)\n' +- '- (string, string, object)\n' +- '- (Model, string, object)\n').replace(/[()]/g, '\\$&');+ it('compileModelSync(model) throws with invalid number of args', () => {+ const expectedMsg = (+ '\'compileModelSync\' method called with incorrect parameters.\n' ++ 'Provided signature: (object) \n' ++ 'Allowed signatures:\n' ++ '- (string, string)\n' ++ '- (Model, string)\n' ++ '- (string, string, object)\n' ++ '- (Model, string, object)\n'+ ).replace(/[()]/g, '\\$&');assert.throws(() => core.compileModelSync(model),@@ -126,54 +123,50 @@ describe('ov basic tests.', () => {});describe('Core.compileModel()', () => {- const tput = { 'PERFORMANCE_HINT': 'THROUGHPUT' };+ const tput = { PERFORMANCE_HINT: 'THROUGHPUT' };it('compileModel(model:Model, deviceName: string, config: {}) ', () => {- core.compileModel(model, 'CPU', tput).then(cm => {+ core.compileModel(model, 'CPU', tput).then((cm) => {assert.deepStrictEqual(cm.output(0).shape, [1, 10]);});-});- it('compileModel(model:model_path, deviceName: string, config: {}) ', () => {- core.compileModel(testXml, 'CPU', tput).then(cm => {+ it('compileModel(model_path, deviceName, config: {}) ', () => {+ core.compileModel(testXml, 'CPU', tput).then((cm) => {assert.equal(cm.inputs.length, 1);});-});it('compileModel(model:model_path, deviceName: string) ', () => {- core.compileModel(testXml, 'CPU').then(cm => {+ core.compileModel(testXml, 'CPU').then((cm) => {assert.deepStrictEqual(cm.output(0).shape, [1, 10]);});-});- it('compileModel(model, device, config) throws when config isn\'t an object', () => {+ it('compileModel(model, device, invalidconfig) throws', () => {assert.throws(() => core.compileModel(model, 'CPU', 'string').then(),- 'Argument #3 must be an Object.'+ 'Argument #3 must be an Object.',);});- it('compileModel(model, device, config) throws when config value is not a string', () => {+ it('compileModel(model, device, invalidConfig) throws', () => {assert.throws(- () => core.compileModel(model, 'CPU', { 'PERFORMANCE_HINT': tput }).then(),- /Cannot convert to ov::Any/+ () =>+ core.compileModel(model, 'CPU', { PERFORMANCE_HINT: tput }).then(),+ /Cannot convert to ov::Any/,);});- it('compileModel(model) throws if the number of arguments is invalid', () => {+ it('compileModel(model) throws with invalid number of args', () => {assert.throws(() => core.compileModel(model).then(),- /Invalid number of arguments/+ /Invalid number of arguments/,);});-});describe('ov.Model/ov.CompiledModel output()', () => {-it('model.output() type', () => {assert.ok(model.output() instanceof ov.Output);});@@ -183,7 +176,6 @@ describe('ov basic tests.', () => {});it('output() methods/properties', () => {-modelLike.forEach((obj) => {assert.strictEqual(obj.outputs.length, 1);// tests for an obj with one output@@ -195,12 +187,10 @@ describe('ov basic tests.', () => {assert.strictEqual(obj.output().getAnyName(), 'fc_out');assert.strictEqual(obj.output().anyName, 'fc_out');});-});});describe('ov.Model/ov.CompiledModel input()', () => {-it('ov.Model.input() type', () => {assert.ok(model.input() instanceof ov.Output);});@@ -211,7 +201,6 @@ describe('ov basic tests.', () => {it('input() methods/properties', () => {modelLike.forEach((obj) => {-assert.strictEqual(typeof obj.input(), 'object');assert.strictEqual(obj.inputs.length, 1);assert.strictEqual(obj.input().toString(), 'data');@@ -223,9 +212,7 @@ describe('ov basic tests.', () => {assert.deepStrictEqual(obj.input(0).shape, [1, 3, 32, 32]);assert.deepStrictEqual(obj.input(0).getShape(), [1, 3, 32, 32]);});-});-});describe('Test exportModel()/importModel()', () => {@@ -234,7 +221,10 @@ describe('ov basic tests.', () => {let res1 = null;before(() => {- tensor = Float32Array.from({ length: 3072 }, () => (Math.random() + epsilon));+ tensor = Float32Array.from(+ { length: 3072 },+ () => Math.random() + epsilon,+ );const core = new ov.Core();const model = core.readModelSync(testXml);const compiledModel = core.compileModelSync(model, 'CPU');@@ -252,7 +242,9 @@ describe('ov basic tests.', () => {});it('Test importModelSync(stream, device, config)', () => {- const newCompiled = core.importModelSync(userStream, 'CPU', { 'NUM_STREAMS': 1 });+ const newCompiled = core.importModelSync(userStream, 'CPU', {+ NUM_STREAMS: 1,+ });const newInferRequest = newCompiled.createInferRequest();const res2 = newInferRequest.infer([tensor]);@@ -262,20 +254,20 @@ describe('ov basic tests.', () => {it('Test importModelSync(stream, device) throws', () => {assert.throws(() => core.importModelSync(epsilon, 'CPU'),- /The first argument must be of type Buffer./+ /The first argument must be of type Buffer./,);});it('Test importModelSync(stream, device) throws', () => {assert.throws(() => core.importModelSync(userStream, tensor),- /The second argument must be of type String./+ /The second argument must be of type String./,);});it('Test importModelSync(stream, device, config: tensor) throws', () => {assert.throws(() => core.importModelSync(userStream, 'CPU', tensor),- /NotFound: Unsupported property 0 by CPU plugin./+ /NotFound: Unsupported property 0 by CPU plugin./,);});@@ -283,7 +275,7 @@ describe('ov basic tests.', () => {const testString = 'test';assert.throws(() => core.importModelSync(userStream, 'CPU', testString),- /Passed Napi::Value must be an object./+ /Passed Napi::Value must be an object./,);});@@ -291,13 +283,13 @@ describe('ov basic tests.', () => {throws', () => {const tmpDir = '/tmp';assert.throws(- () => core.importModelSync(userStream, 'CPU', { 'CACHE_DIR': tmpDir }),- /Unsupported property CACHE_DIR by CPU plugin./+ () => core.importModelSync(userStream, 'CPU', { CACHE_DIR: tmpDir }),+ /Unsupported property CACHE_DIR by CPU plugin./,);});it('Test importModel(stream, device)', () => {- core.importModel(userStream, 'CPU').then(newCompiled => {+ core.importModel(userStream, 'CPU').then((newCompiled) => {const newInferRequest = newCompiled.createInferRequest();const res2 = newInferRequest.infer([tensor]);assert.deepStrictEqual(res1['fc_out'].data[0], res2['fc_out'].data[0]);@@ -305,26 +297,30 @@ describe('ov basic tests.', () => {});it('Test importModel(stream, device, config)', () => {- core.importModel(userStream, 'CPU', { 'NUM_STREAMS': 1 }).then(- newCompiled => {+ core+ .importModel(userStream, 'CPU', { NUM_STREAMS: 1 })+ .then((newCompiled) => {const newInferRequest = newCompiled.createInferRequest();const res2 = newInferRequest.infer([tensor]);- assert.deepStrictEqual(res1['fc_out'].data[0], res2['fc_out'].data[0]);+ assert.deepStrictEqual(+ res1['fc_out'].data[0],+ res2['fc_out'].data[0],+ );});});it('Test importModel(stream, device) throws', () => {assert.throws(() => core.importModel(epsilon, 'CPU').then(),- /'importModel' method called with incorrect parameters./+ /'importModel' method called with incorrect parameters./,);});it('Test importModel(stream, device) throws', () => {assert.throws(() => core.importModel(userStream, tensor).then(),- /'importModel' method called with incorrect parameters./+ /'importModel' method called with incorrect parameters./,);});@@ -332,10 +328,8 @@ describe('ov basic tests.', () => {const testString = 'test';assert.throws(() => core.importModel(userStream, 'CPU', testString).then(),- /'importModel' method called with incorrect parameters./+ /'importModel' method called with incorrect parameters./,);});-});-});diff --git a/src/bindings/js/node/tests/unit/compiled_model.test.js b/src/bindings/js/node/tests/unit/compiled_model.test.jsindex d433cf3b8e9..86c7bf4b7d1 100644--- a/src/bindings/js/node/tests/unit/compiled_model.test.js+++ b/src/bindings/js/node/tests/unit/compiled_model.test.js@@ -8,8 +8,6 @@ const { describe, it, before, beforeEach } = require('node:test');const { testModels, getModelPath, isModelAvailable } = require('./utils.js');describe('ov.CompiledModel tests', () => {--let testXml = null;let core = null;let compiledModel = null;@@ -19,10 +17,10 @@ describe('ov.CompiledModel tests', () => {testXml = getModelPath().xml;core = new ov.Core();});-+beforeEach(() => {const properties = {- 'AUTO_BATCH_TIMEOUT': '1',+ AUTO_BATCH_TIMEOUT: '1',};compiledModel = core.compileModelSync(testXml, 'BATCH:CPU', properties);});@@ -34,51 +32,55 @@ describe('ov.CompiledModel tests', () => {it('throws an error when called without arguments', () => {assert.throws(() => compiledModel.getProperty(),- /'getProperty' method called with incorrect parameters/+ /'getProperty' method called with incorrect parameters/,);});- it('throws an error when called with property name that does not exists', () => {- assert.throws(- () => compiledModel.getProperty('PROPERTY_THAT_DOES_NOT_EXIST')+ it('throws when called with property name that does not exists', () => {+ assert.throws(() =>+ compiledModel.getProperty('PROPERTY_THAT_DOES_NOT_EXIST'),);});});describe('setProperty()', () => {it('sets a properties for compiled model', () => {- const properties = {'AUTO_BATCH_TIMEOUT': '1000'};+ const properties = { AUTO_BATCH_TIMEOUT: '1000' };assert.doesNotThrow(() => compiledModel.setProperty(properties));});it('throws an error when called without an object argument', () => {assert.throws(() => compiledModel.setProperty(),- /'setProperty' method called with incorrect parameters/+ /'setProperty' method called with incorrect parameters/,);});it('throws an error when called with wrong argument', () => {assert.throws(() => compiledModel.setProperty(123),- /'setProperty' method called with incorrect parameters/+ /'setProperty' method called with incorrect parameters/,);});it('throws an error when called with multiple arguments', () => {assert.throws(- () => compiledModel.setProperty({'PERFORMANCE_HINT': 'THROUGHPUT'}, {'NUM_STREAMS': 'AUTO'}),- /'setProperty' method called with incorrect parameters/+ () =>+ compiledModel.setProperty(+ { PERFORMANCE_HINT: 'THROUGHPUT' },+ { NUM_STREAMS: 'AUTO' },+ ),+ /'setProperty' method called with incorrect parameters/,);});it('returns the set property of the compiled model', () => {- const properties = {'AUTO_BATCH_TIMEOUT': '123'};+ const properties = { AUTO_BATCH_TIMEOUT: '123' };compiledModel.setProperty(properties);assert.strictEqual(compiledModel.getProperty('AUTO_BATCH_TIMEOUT'), 123);});it('retains the last set property when set multiple times', () => {- compiledModel.setProperty({'AUTO_BATCH_TIMEOUT': '321'});- compiledModel.setProperty({'AUTO_BATCH_TIMEOUT': '132'});+ compiledModel.setProperty({ AUTO_BATCH_TIMEOUT: '321' });+ compiledModel.setProperty({ AUTO_BATCH_TIMEOUT: '132' });assert.strictEqual(compiledModel.getProperty('AUTO_BATCH_TIMEOUT'), 132);});diff --git a/src/bindings/js/node/tests/unit/core.test.js b/src/bindings/js/node/tests/unit/core.test.jsindex fac64e48927..6cf431a38b5 100644--- a/src/bindings/js/node/tests/unit/core.test.js+++ b/src/bindings/js/node/tests/unit/core.test.js@@ -20,7 +20,7 @@ describe('ov.Core tests', () => {it('Core.setProperty()', () => {const tmpDir = '/tmp';- core.setProperty({ 'CACHE_DIR': tmpDir });+ core.setProperty({ CACHE_DIR: tmpDir });const cacheDir = core.getProperty('CACHE_DIR');@@ -30,7 +30,7 @@ describe('ov.Core tests', () => {it('Core.setProperty(\'CPU\')', () => {const tmpDir = '/tmp';- core.setProperty('CPU', { 'CACHE_DIR': tmpDir });+ core.setProperty('CPU', { CACHE_DIR: tmpDir });const cacheDir = core.getProperty('CPU', 'CACHE_DIR');@@ -38,7 +38,10 @@ describe('ov.Core tests', () => {});it('Core.getProperty(\'CPU\', \'SUPPORTED_PROPERTIES\') is Array', () => {- const supportedPropertiesArray = core.getProperty('CPU', 'SUPPORTED_PROPERTIES');+ const supportedPropertiesArray = core.getProperty(+ 'CPU',+ 'SUPPORTED_PROPERTIES',+ );assert.ok(Array.isArray(supportedPropertiesArray));});@@ -46,7 +49,7 @@ describe('ov.Core tests', () => {it('Core.setProperty(\'CPU\', { \'NUM_STREAMS\': 5 })', () => {const streams = 5;- core.setProperty('CPU', { 'NUM_STREAMS': streams });+ core.setProperty('CPU', { NUM_STREAMS: streams });const result = core.getProperty('CPU', 'NUM_STREAMS');assert.equal(result, streams);@@ -55,7 +58,7 @@ describe('ov.Core tests', () => {it('Core.setProperty(\'CPU\', { \'INFERENCE_NUM_THREADS\': 3 })', () => {const threads = 3;- core.setProperty('CPU', { 'INFERENCE_NUM_THREADS': threads });+ core.setProperty('CPU', { INFERENCE_NUM_THREADS: threads });const result = core.getProperty('CPU', 'INFERENCE_NUM_THREADS');assert.equal(result, threads);@@ -64,7 +67,7 @@ describe('ov.Core tests', () => {it('Core.addExtension() with empty parameters', () => {assert.throws(() => core.addExtension(),- /addExtension method applies one argument of string type/+ /addExtension method applies one argument of string type/,);});@@ -73,7 +76,7 @@ describe('ov.Core tests', () => {assert.throws(() => core.addExtension(notExistsExt),- /Cannot load library 'not_exists'/+ /Cannot load library 'not_exists'/,);});diff --git a/src/bindings/js/node/tests/unit/infer_request.test.js b/src/bindings/js/node/tests/unit/infer_request.test.jsindex d1ee057cd77..3f993ef70f2 100644--- a/src/bindings/js/node/tests/unit/infer_request.test.js+++ b/src/bindings/js/node/tests/unit/infer_request.test.js@@ -11,7 +11,6 @@ const epsilon = 0.5; // To avoid very small numbersconst testXml = getModelPath().xml;describe('ov.InferRequest tests', () => {-let compiledModel = null;let tensorData = null;let tensor = null;@@ -25,17 +24,12 @@ describe('ov.InferRequest tests', () => {const model = core.readModelSync(testXml);compiledModel = core.compileModelSync(model, 'CPU');- tensorData = Float32Array.from({ length: 3072 }, () => (Math.random() + epsilon));- tensor = new ov.Tensor(- ov.element.f32,- [1, 3, 32, 32],- tensorData,- );- resTensor = new ov.Tensor(- ov.element.f32,- [1, 10],- tensorData.slice(-10),+ tensorData = Float32Array.from(+ { length: 3072 },+ () => Math.random() + epsilon,);+ tensor = new ov.Tensor(ov.element.f32, [1, 3, 32, 32], tensorData);+ resTensor = new ov.Tensor(ov.element.f32, [1, 10], tensorData.slice(-10));tensorLike = [tensor, tensorData];});@@ -45,7 +39,7 @@ describe('ov.InferRequest tests', () => {inferRequest = compiledModel.createInferRequest();});- it('Test infer(inputData: {inputName: string]: Tensor[]/TypedArray[]}', () => {+ it('infer(inputData: {inputName: string]: Tensor[]/TypedArray[]}', () => {tensorLike.forEach((tl) => {const result = inferRequest.infer({ data: tl });assert.deepStrictEqual(Object.keys(result), ['fc_out']);@@ -62,72 +56,77 @@ describe('ov.InferRequest tests', () => {});it('Test infer(TypedArray) throws', () => {- assert.throws(- () => inferRequest.infer(tensorData),- {message: /TypedArray cannot be passed directly into infer\(\) method./});+ assert.throws(() => inferRequest.infer(tensorData), {+ message: /TypedArray cannot be passed directly into infer\(\) method./,+ });});it('Test for invalid input data', () => {const buffer = new ArrayBuffer(tensorData.length);const inputMessagePairs = [['string', 'Cannot create a tensor from the passed Napi::Value.'],- [tensorData.slice(-10), 'Memory allocated using shape and element::type mismatch passed data\'s size'],- [new Float32Array(buffer, 4), 'TypedArray.byteOffset has to be equal to zero.'],+ [+ tensorData.slice(-10),+ /Memory allocated using shape and element::type mismatch/,+ ],+ [+ new Float32Array(buffer, 4),+ 'TypedArray.byteOffset has to be equal to zero.',+ ],[{}, /Invalid argument/], // Test for object that is not Tensor];- inputMessagePairs.forEach( ([tl, msg]) => {-+ inputMessagePairs.forEach(([tl, msg]) => {assert.throws(() => inferRequest.infer([tl]),- { message: new RegExp(msg) }, 'infer([data]) throws');+ { message: new RegExp(msg) },+ 'infer([data]) throws',+ );assert.throws(- () => inferRequest.infer({data: tl}),- { message: new RegExp(msg) }, 'infer({ data: tl}) throws');-+ () => inferRequest.infer({ data: tl }),+ { message: new RegExp(msg) },+ 'infer({ data: tl}) throws',+ );});-});-});describe('inferAsync() method', () => {let inferRequest = null;- before( () => {+ before(() => {inferRequest = compiledModel.createInferRequest();});it('Test inferAsync(inputData: { [inputName: string]: Tensor })', () => {- inferRequest.inferAsync({ data: tensor }).then(result => {+ inferRequest.inferAsync({ data: tensor }).then((result) => {assert.ok(result['fc_out'] instanceof ov.Tensor);assert.deepStrictEqual(Object.keys(result), ['fc_out']);- assert.deepStrictEqual(result['fc_out'].data.length, 10);}- );+ assert.deepStrictEqual(result['fc_out'].data.length, 10);+ });});it('Test inferAsync(inputData: Tensor[])', () => {- inferRequest.inferAsync([ tensor ]).then(result => {+ inferRequest.inferAsync([tensor]).then((result) => {assert.ok(result['fc_out'] instanceof ov.Tensor);assert.deepStrictEqual(Object.keys(result), ['fc_out']);assert.deepStrictEqual(result['fc_out'].data.length, 10);});});- it('Test inferAsync([data]) throws: Cannot create a tensor from the passed Napi::Value.', () => {+ it('Test inferAsync([data]) throws', () => {assert.throws(() => inferRequest.inferAsync(['string']).then(),- /Cannot create a tensor from the passed Napi::Value./+ /Cannot create a tensor from the passed Napi::Value./,);});- it('Test inferAsync({ data: "string"}) throws: Cannot create a tensor from the passed Napi::Value.', () => {+ it('Test inferAsync({ data: "string"}) throws', () => {assert.throws(- () => inferRequest.inferAsync({data: 'string'}).then(),- /Cannot create a tensor from the passed Napi::Value./+ () => inferRequest.inferAsync({ data: 'string' }).then(),+ /Cannot create a tensor from the passed Napi::Value./,);});-});describe('setters', () => {@@ -136,128 +135,117 @@ describe('ov.InferRequest tests', () => {inferRequest = compiledModel.createInferRequest();});- it('Test setInputTensor(tensor)', () => {+ it('setInputTensor(tensor)', () => {inferRequest.setInputTensor(tensor);const t1 = inferRequest.getInputTensor();assert.deepStrictEqual(tensor.data[0], t1.data[0]);});- it('Test setInputTensor(object) throws when passed object is not a Tensor.', () => {- assert.throws(- () => inferRequest.setInputTensor({}),- {message: /Argument #[0-9]+ must be a Tensor./}- );+ it('setInputTensor(object) throws if object is not a Tensor.', () => {+ assert.throws(() => inferRequest.setInputTensor({}), {+ message: /Argument #[0-9]+ must be a Tensor./,+ });});- it('Test setInputTensor(idx, tensor)', () => {+ it('setInputTensor(idx, tensor)', () => {inferRequest.setInputTensor(0, tensor);const t1 = inferRequest.getInputTensor();assert.deepStrictEqual(tensor.data[0], t1.data[0]);});- it('Test setInputTensor(idx, tensor) throws', () => {+ it('setInputTensor(idx, tensor) throws', () => {const testIdx = 10;- assert.throws (- () => inferRequest.setInputTensor(testIdx, tensor),- {message: /Input port for index [0-9]+ was not found!/}- );+ assert.throws(() => inferRequest.setInputTensor(testIdx, tensor), {+ message: /Input port for index [0-9]+ was not found!/,+ });});- it('Test setInputTensor(idx, object) throws when passed object is not a Tensor.', () => {- assert.throws(- () => inferRequest.setInputTensor(0, {}),- {message: /Argument #[0-9]+ must be a Tensor./}- );+ it('setInputTensor(idx, object) throws if object is not a Tensor.', () => {+ assert.throws(() => inferRequest.setInputTensor(0, {}), {+ message: /Argument #[0-9]+ must be a Tensor./,+ });});- it('Test setInputTensor(tensor, tensor) throws', () => {- assert.throws(- () => inferRequest.setInputTensor(resTensor, tensor),- {message: / invalid argument./}- );+ it('setInputTensor(tensor, tensor) throws', () => {+ assert.throws(() => inferRequest.setInputTensor(resTensor, tensor), {+ message: / invalid argument./,+ });});- it('Test setOutputTensor(tensor)', () => {+ it('setOutputTensor(tensor)', () => {inferRequest.setOutputTensor(resTensor);const res2 = inferRequest.getOutputTensor();assert.deepStrictEqual(resTensor.data[0], res2.data[0]);});- it('Test setOutputTensor(object) throws when passed object is not a Tensor.', () => {- assert.throws(- () => inferRequest.setOutputTensor({}),- {message: /Argument #[0-9]+ must be a Tensor./}- );+ it('setOutputTensor(object) throws if object is not a Tensor.', () => {+ assert.throws(() => inferRequest.setOutputTensor({}), {+ message: /Argument #[0-9]+ must be a Tensor./,+ });});- it('Test setOutputTensor(idx, tensor) throws', () => {+ it('setOutputTensor(idx, tensor) throws', () => {const testIdx = 10;- assert.throws (- () => inferRequest.setOutputTensor(testIdx, tensor),- {message: /Output port for index [0-9]+ was not found!/}- );+ assert.throws(() => inferRequest.setOutputTensor(testIdx, tensor), {+ message: /Output port for index [0-9]+ was not found!/,+ });});- it('Test setOutputTensor(idx, tensor)', () => {+ it('setOutputTensor(idx, tensor)', () => {inferRequest.setOutputTensor(0, resTensor);const res2 = inferRequest.getOutputTensor();assert.deepStrictEqual(resTensor.data[0], res2.data[0]);});- it('Test setOutputTensor(idx, tensor) throws when passed object is not a Tensor.', () => {- assert.throws(- () => inferRequest.setOutputTensor(0, {}),- {message: /Argument #[0-9]+ must be a Tensor./}- );+ it('setOutputTensor(idx, object) throws if object is not a Tensor.', () => {+ assert.throws(() => inferRequest.setOutputTensor(0, {}), {+ message: /Argument #[0-9]+ must be a Tensor./,+ });});- it('Test setOutputTensor() - pass two tensors', () => {- assert.throws(- () => inferRequest.setOutputTensor(resTensor, tensor),- {message: / invalid argument./});+ it('setOutputTensor() - pass two tensors', () => {+ assert.throws(() => inferRequest.setOutputTensor(resTensor, tensor), {+ message: / invalid argument./,+ });});- it('Test setTensor(string, tensor)', () => {+ it('setTensor(string, tensor)', () => {inferRequest.setTensor('fc_out', resTensor);const res2 = inferRequest.getTensor('fc_out');assert.ok(res2 instanceof ov.Tensor);assert.deepStrictEqual(resTensor.data[0], res2.data[0]);});- it('Test setTensor(string, object) - throws', () => {+ it('setTensor(string, object) - throws', () => {const testName = 'testName';- assert.throws(- () => inferRequest.setTensor(testName, tensor),- {message: /Port for tensor name testName was not found./});+ assert.throws(() => inferRequest.setTensor(testName, tensor), {+ message: /Port for tensor name testName was not found./,+ });});- it('Test setTensor(string, object) - throws', () => {- assert.throws(- () => inferRequest.setTensor('fc_out', {}),- {message: /Argument #[0-9]+ must be a Tensor./});+ it('setTensor(string, object) - throws', () => {+ assert.throws(() => inferRequest.setTensor('fc_out', {}), {+ message: /Argument #[0-9]+ must be a Tensor./,+ });});- it('Test setTensor(string, tensor) - pass one arg', () => {- assert.throws(- () => inferRequest.setTensor('fc_out'),- {message: / invalid argument./}- );+ it('setTensor(string, tensor) - pass one arg', () => {+ assert.throws(() => inferRequest.setTensor('fc_out'), {+ message: / invalid argument./,+ });});- it('Test setTensor(string, tensor) - pass args in wrong order', () => {- assert.throws(- () => inferRequest.setTensor(resTensor, 'fc_out'),- {message: / invalid argument./}- );+ it('setTensor(string, tensor) - pass args in wrong order', () => {+ assert.throws(() => inferRequest.setTensor(resTensor, 'fc_out'), {+ message: / invalid argument./,+ });});- it('Test setTensor(string, tensor) - pass number as first arg', () => {- assert.throws(- () => inferRequest.setTensor(123, 'fc_out'),- {message: / invalid argument/}- );+ it('setTensor(string, tensor) - pass number as first arg', () => {+ assert.throws(() => inferRequest.setTensor(123, 'fc_out'), {+ message: / invalid argument/,+ });});-});describe('getters', () => {@@ -310,6 +298,5 @@ describe('ov.InferRequest tests', () => {const res1 = ir.infer([tensorData]);assert.deepStrictEqual(res1['fc_out'].data[0], res2['fc_out'].data[0]);});-});});diff --git a/src/bindings/js/node/tests/unit/model.test.js b/src/bindings/js/node/tests/unit/model.test.jsindex e71226e756e..f66c119578f 100644--- a/src/bindings/js/node/tests/unit/model.test.js+++ b/src/bindings/js/node/tests/unit/model.test.js@@ -8,7 +8,6 @@ const { describe, it, before, beforeEach } = require('node:test');const { testModels, getModelPath, isModelAvailable } = require('./utils.js');describe('ov.Model tests', () => {-let testXml = null;let core = null;let model = null;@@ -24,12 +23,12 @@ describe('ov.Model tests', () => {});describe('Model.isDynamic()', () => {- it('should return a boolean value indicating if the model is dynamic', () => {+ it('should return a boolean value type', () => {const result = model.isDynamic();assert.strictEqual(typeof result,'boolean',- 'isDynamic() should return a boolean value'+ 'isDynamic() should return a boolean value',);});@@ -39,7 +38,7 @@ describe('ov.Model tests', () => {model.isDynamic('unexpected argument');},/^Error: isDynamic\(\) does not accept any arguments\.$/,- 'Expected isDynamic to throw an error when called with arguments'+ 'Expected isDynamic to throw an error when called with arguments',);});@@ -48,20 +47,20 @@ describe('ov.Model tests', () => {assert.strictEqual(model.isDynamic(),expectedStatus,- 'Expected isDynamic to return false for a static model'+ 'Expected isDynamic to return false for a static model',);});});describe('Model.getFriendlyName()', () => {- it('returns the unique name of the model if no friendly name is set', () => {+ it('returns model\'s unique name if no friendly name is set', () => {const expectedName = 'test_model';assert.strictEqual(model.getFriendlyName(), expectedName);});it('throws an error when called with arguments', () => {assert.throws(() => model.getFriendlyName('unexpected argument'),- /getFriendlyName\(\) does not take any arguments/+ /getFriendlyName\(\) does not take any arguments/,);});});@@ -69,18 +68,18 @@ describe('ov.Model tests', () => {it('throws an error when called without a string argument', () => {assert.throws(() => model.setFriendlyName(),- /Expected a single string argument for the friendly name/+ /Expected a single string argument for the friendly name/,);assert.throws(() => model.setFriendlyName(123),- /Expected a single string argument for the friendly name/+ /Expected a single string argument for the friendly name/,);});it('throws an error when called with multiple arguments', () => {assert.throws(() => model.setFriendlyName('Name1', 'Name2'),- /Expected a single string argument for the friendly name/+ /Expected a single string argument for the friendly name/,);});@@ -103,85 +102,94 @@ describe('ov.Model tests', () => {});describe('Model.getOutputSize()', () => {-- it('should return a number indicating number of outputs for the model', () => {+ it('getOutputSize() should return a number', () => {const result = model.getOutputSize();- assert.strictEqual(typeof result, 'number', 'getOutputSize() should return a number');+ assert.strictEqual(typeof result, 'number');});it('should not accept any arguments', () => {assert.throws(() => {model.getOutputSize('unexpected argument');- }, /^Error: getOutputSize\(\) does not accept any arguments\.$/, 'Expected getOutputSize to throw an error when called with arguments');+ }, /^Error: getOutputSize\(\) does not accept any arguments\.$/);});it('should return 1 for the default model', () => {- assert.strictEqual(model.getOutputSize(), 1, 'Expected getOutputSize to return 1 for the default model');+ assert.strictEqual(model.getOutputSize(), 1);});});describe('Model.getOutputElementType()', () => {- it('should return a string for the element type ', () => {+ it('should return a string', () => {const result = model.getOutputElementType(0);- assert.strictEqual(typeof result, 'string',- 'getOutputElementType() should return a string');+ assert.strictEqual(typeof result, 'string');});it('should accept a single integer argument', () => {- assert.throws(() => {- model.getOutputElementType();- }, /'getOutputElementType' method called with incorrect parameters/,- 'Should throw when called without arguments');+ assert.throws(+ () => {+ model.getOutputElementType();+ },+ /'getOutputElementType' method called with incorrect parameters/,+ 'Should throw when called without arguments',+ );- assert.throws(() => {- model.getOutputElementType('unexpected argument');- }, /'getOutputElementType' method called with incorrect parameters/,- 'Should throw on non-number argument');+ assert.throws(+ () => {+ model.getOutputElementType('unexpected argument');+ },+ /'getOutputElementType' method called with incorrect parameters/,+ 'Should throw on non-number argument',+ );- assert.throws(() => {- model.getOutputElementType(0, 1);- }, /'getOutputElementType' method called with incorrect parameters/,- 'Should throw on multiple arguments');+ assert.throws(+ () => {+ model.getOutputElementType(0, 1);+ },+ /'getOutputElementType' method called with incorrect parameters/,+ 'Should throw on multiple arguments',+ );- assert.throws(() => {- model.getOutputElementType(3.14);- }, /'getOutputElementType' method called with incorrect parameters/,- 'Should throw on non-integer number');+ assert.throws(+ () => {+ model.getOutputElementType(3.14);+ },+ /'getOutputElementType' method called with incorrect parameters/,+ 'Should throw on non-integer number',+ );});it('should return a valid element type for the default model', () => {const elementType = model.getOutputElementType(0);- assert.ok(typeof elementType === 'string' && elementType.length > 0,- `Expected a non-empty string, got ${elementType}`);+ assert.ok(+ typeof elementType === 'string' && elementType.length > 0,+ `Expected a non-empty string, got ${elementType}`,+ );});it('should throw an error for out-of-range index', () => {const outputSize = model.getOutputSize();- assert.throws(- () => { model.getOutputElementType(outputSize); },- /^Error: /,- 'Should throw for out-of-range index'- );+ assert.throws(() => {+ model.getOutputElementType(outputSize);+ }, /^Error: /);});});describe('Model.clone()', () => {it('should return an object of type model', () => {const clonedModel = model.clone();- assert.ok(clonedModel instanceof ov.Model, 'clone() should return a model');+ assert.ok(clonedModel instanceof ov.Model);});it('should return a model that is a clone of the calling model', () => {const clonedModel = model.clone();- assert.deepStrictEqual(clonedModel, model, 'Cloned Model should be exactly equal to the calling model');+ assert.deepStrictEqual(clonedModel, model);});it('should not accept any arguments', () => {assert.throws(() => model.clone('Unexpected argument').then(),- /'clone' method called with incorrect parameters./+ /'clone' method called with incorrect parameters./,);});});-});diff --git a/src/bindings/js/node/tests/unit/pre_post_processor.test.js b/src/bindings/js/node/tests/unit/pre_post_processor.test.jsindex adb02dc082e..04bef1fead6 100644--- a/src/bindings/js/node/tests/unit/pre_post_processor.test.js+++ b/src/bindings/js/node/tests/unit/pre_post_processor.test.js@@ -8,7 +8,6 @@ const { describe, it, before, beforeEach } = require('node:test');const { testModels, getModelPath, isModelAvailable } = require('./utils.js');describe('ov.preprocess.PrePostProcessor tests', () => {-let testXml = null;let core = null;let model = null;@@ -17,7 +16,6 @@ describe('ov.preprocess.PrePostProcessor tests', () => {await isModelAvailable(testModels.testModelFP32);testXml = getModelPath().xml;core = new ov.Core();-});beforeEach(() => {@@ -25,192 +23,278 @@ describe('ov.preprocess.PrePostProcessor tests', () => {});describe('PrePostProcess', () => {-it('input() ', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input());+ new ov.preprocess.PrePostProcessor(model).input(),+ );});it('input(size_t input_index)', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0));+ new ov.preprocess.PrePostProcessor(model).input(0),+ );});it('input(const std::string& tensor_name)', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input('data'));+ new ov.preprocess.PrePostProcessor(model).input('data'),+ );});it('output() ', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).output());+ new ov.preprocess.PrePostProcessor(model).output(),+ );});it('output(size_t output_index)', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).output(0));+ new ov.preprocess.PrePostProcessor(model).output(0),+ );});it('output(const std::string& tensor_name)', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).output('fc_out'));+ new ov.preprocess.PrePostProcessor(model).output('fc_out'),+ );});-});describe('InputInfo', () => {it('tensor()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor());+ new ov.preprocess.PrePostProcessor(model).input(0).tensor(),+ );});it('preprocess()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).preprocess());+ new ov.preprocess.PrePostProcessor(model).input(0).preprocess(),+ );});it('model()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).model());+ new ov.preprocess.PrePostProcessor(model).input(0).model(),+ );});it('tensor(param) throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor(0),- /Function does not take any parameters./);+ assert.throws(+ () => new ov.preprocess.PrePostProcessor(model).input(0).tensor(0),+ /Function does not take any parameters./,+ );});it('preprocess(param) throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).preprocess(0),- /Function does not take any parameters./);+ assert.throws(+ () => new ov.preprocess.PrePostProcessor(model).input(0).preprocess(0),+ /Function does not take any parameters./,+ );});it('model(param) throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).model(0),- /Function does not take any parameters./);+ assert.throws(+ () => new ov.preprocess.PrePostProcessor(model).input(0).model(0),+ /Function does not take any parameters./,+ );});it('tensor().setElementType()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor().setElementType(ov.element.u8));+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .tensor()+ .setElementType(ov.element.u8),+ );});it('tensor().setElementType() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor().setElementType(),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .tensor()+ .setElementType(),+ /Wrong number of parameters./,+ );});it('tensor().setElementType() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor().setElementType('invalidType'),- /Cannot create ov::element::Type/);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .tensor()+ .setElementType('invalidType'),+ /Cannot create ov::element::Type/,+ );});it('tensor().SetShape()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor().setShape([1, 10]));+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .tensor()+ .setShape([1, 10]),+ );});it('tensor().SetShape() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor().setShape(),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .tensor()+ .setShape(),+ /Wrong number of parameters./,+ );});it('tensor().setLayout()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor().setLayout('NHWC'));+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .tensor()+ .setLayout('NHWC'),+ );});it('tensor().setLayout() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).tensor().setLayout(),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .tensor()+ .setLayout(),+ /Wrong number of parameters./,+ );});it('preprocess().resize()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).preprocess().resize(- ov.preprocess.resizeAlgorithm.RESIZE_LINEAR,- ));+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .preprocess()+ .resize(ov.preprocess.resizeAlgorithm.RESIZE_LINEAR),+ );});it('preprocess().resize() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).preprocess().resize(- ov.preprocess.resizeAlgorithm.RESIZE_LINEAR, 'extraArg',- ),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .preprocess()+ .resize(ov.preprocess.resizeAlgorithm.RESIZE_LINEAR, 'extraArg'),+ /Wrong number of parameters./,+ );});it('preprocess().resize() no arg throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).preprocess().resize(),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .preprocess()+ .resize(),+ /Wrong number of parameters./,+ );});it('model().setLayout()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).input(0).model().setLayout('NCHW'));+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .model()+ .setLayout('NCHW'),+ );});it('model().setLayout() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).model().setLayout('NCHW', 'extraArg'),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .model()+ .setLayout('NCHW', 'extraArg'),+ /Wrong number of parameters./,+ );});it('model().setLayout() throws', () => {assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).input(0).model().setLayout('invalidLayout')+ new ov.preprocess.PrePostProcessor(model)+ .input(0)+ .model()+ .setLayout('invalidLayout'),);});-});describe('OutputInfo', () => {it('tensor()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).output(0).tensor());+ new ov.preprocess.PrePostProcessor(model).output(0).tensor(),+ );});it('tensor(param) throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).output(0).tensor(0),- /Function does not take any parameters./);+ assert.throws(+ () => new ov.preprocess.PrePostProcessor(model).output(0).tensor(0),+ /Function does not take any parameters./,+ );});it('tensor().setElementType()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).output(0).tensor().setElementType(ov.element.u8));+ new ov.preprocess.PrePostProcessor(model)+ .output(0)+ .tensor()+ .setElementType(ov.element.u8),+ );});it('tensor().setElementType() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).output(0).tensor().setElementType(),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .output(0)+ .tensor()+ .setElementType(),+ /Wrong number of parameters./,+ );});it('tensor().setElementType() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).output(0).tensor().setElementType('invalidType'),- /Cannot create ov::element::Type/);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .output(0)+ .tensor()+ .setElementType('invalidType'),+ /Cannot create ov::element::Type/,+ );});it('tensor().setLayout()', () => {assert.doesNotThrow(() =>- new ov.preprocess.PrePostProcessor(model).output(0).tensor().setLayout('NHWC'));+ new ov.preprocess.PrePostProcessor(model)+ .output(0)+ .tensor()+ .setLayout('NHWC'),+ );});it('tensor().setLayout() throws', () => {- assert.throws(() =>- new ov.preprocess.PrePostProcessor(model).output(0).tensor().setLayout(),- /Wrong number of parameters./);+ assert.throws(+ () =>+ new ov.preprocess.PrePostProcessor(model)+ .output(0)+ .tensor()+ .setLayout(),+ /Wrong number of parameters./,+ );});-});-});diff --git a/src/bindings/js/node/tests/unit/read_model.test.js b/src/bindings/js/node/tests/unit/read_model.test.jsindex ab0add15d59..902ee2d963d 100644--- a/src/bindings/js/node/tests/unit/read_model.test.js+++ b/src/bindings/js/node/tests/unit/read_model.test.js@@ -11,11 +11,10 @@ const { testModels, isModelAvailable, getModelPath } = require('./utils.js');const { xml: modelPath, bin: weightsPath } = getModelPath();describe('Tests for reading model.', () => {-let modelFile = null;let modelStr = null;let weightsFile = null;- let weightsTensor= null;+ let weightsTensor = null;let core = null;before(async () => {@@ -27,7 +26,11 @@ describe('Tests for reading model.', () => {beforeEach(() => {core = new ov.Core();- weightsTensor = new ov.Tensor(ov.element.u8, [weightsFile.buffer.byteLength], new Uint8Array(weightsFile.buffer));+ weightsTensor = new ov.Tensor(+ ov.element.u8,+ [weightsFile.buffer.byteLength],+ new Uint8Array(weightsFile.buffer),+ );});describe('Core.readModeSync', () => {@@ -51,10 +54,7 @@ describe('Tests for reading model.', () => {});it('readModelSync(modelString, weightsTensor) ', () => {- const model = core.readModelSync(- modelStr,- weightsTensor,- );+ const model = core.readModelSync(modelStr, weightsTensor);assert.ok(model instanceof ov.Model);assert.equal(model.inputs.length, 1);});@@ -81,15 +81,12 @@ describe('Tests for reading model.', () => {});it('readModel(modelString, weightsTensor) ', async () => {- const model = await core.readModel(- modelStr,- weightsTensor,- );+ const model = await core.readModel(modelStr, weightsTensor);assert.ok(model instanceof ov.Model);assert.equal(model.inputs.length, 1);});- it('readModel(modelUint8ArrayBuffer, weightsUint8ArrayBuffer) ', async () => {+ it('readModel(Uint8ArrayBuffer, Uint8ArrayBuffer) ', async () => {const model = await core.readModel(new Uint8Array(modelFile.buffer),new Uint8Array(weightsFile.buffer),@@ -97,5 +94,4 @@ describe('Tests for reading model.', () => {assert.equal(model.inputs.length, 1);});});-});diff --git a/src/bindings/js/node/tests/unit/tensor.test.js b/src/bindings/js/node/tests/unit/tensor.test.jsindex 5f03030d98c..656bdf9b122 100644--- a/src/bindings/js/node/tests/unit/tensor.test.js+++ b/src/bindings/js/node/tests/unit/tensor.test.js@@ -8,74 +8,112 @@ const { test, describe, it, before } = require('node:test');const getRandomBigInt = require('random-bigint');describe('ov.Tensor tests', () => {-let shape = null;let elemNum = null;let data = null;- let params =null;+ let params = null;before(() => {shape = [1, 3, 224, 224];elemNum = 1 * 3 * 224 * 224;- data = Float32Array.from({ length: elemNum }, () => Math.random() );+ data = Float32Array.from({ length: elemNum }, () => Math.random());params = [- [ov.element.i8, 'i8', Int8Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.u8, 'u8', Uint8Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.i16, 'i16', Int16Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.u16, 'u16', Uint16Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.i32, 'i32', Int32Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.u32, 'u32', Uint32Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.f32, 'f32', Float32Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.f64, 'f64', Float64Array.from({ length: elemNum }, () => Math.random() )],- [ov.element.i64, 'i64', BigInt64Array.from({ length: elemNum }, () => getRandomBigInt(10) )],- [ov.element.u64, 'u64', BigUint64Array.from({ length: elemNum }, () => getRandomBigInt(10) )],+ [+ ov.element.i8,+ 'i8',+ Int8Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.u8,+ 'u8',+ Uint8Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.i16,+ 'i16',+ Int16Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.u16,+ 'u16',+ Uint16Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.i32,+ 'i32',+ Int32Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.u32,+ 'u32',+ Uint32Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.f32,+ 'f32',+ Float32Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.f64,+ 'f64',+ Float64Array.from({ length: elemNum }, () => Math.random()),+ ],+ [+ ov.element.i64,+ 'i64',+ BigInt64Array.from({ length: elemNum }, () => getRandomBigInt(10)),+ ],+ [+ ov.element.u64,+ 'u64',+ BigUint64Array.from({ length: elemNum }, () => getRandomBigInt(10)),+ ],];});test('Test for number of arguments in tensor', () => {- assert.throws( () => new ov.Tensor(ov.element.f32, shape, data, params),- {message: /Invalid number of arguments for Tensor constructor./});+ assert.throws(() => new ov.Tensor(ov.element.f32, shape, data, params), {+ message: /Invalid number of arguments for Tensor constructor./,+ });});- describe('Tensor without data parameters', () => {- it('Tensor should have array with zeros and numbers of elements according to the shape', () => {- const tensor = new ov.Tensor(ov.element.f32, shape);- assert.strictEqual(tensor.data.length, elemNum);- });+ test('Tensor without data parameters', () => {+ const tensor = new ov.Tensor(ov.element.f32, shape);+ assert.strictEqual(tensor.data.length, elemNum);});describe('Tensor data', () => {it('set tensor data with element type', () => {- params.forEach(([type, stringType, data]) => {+ params.forEach(([type, , data]) => {const tensor = new ov.Tensor(type, shape, data);assert.deepStrictEqual(tensor.data, data);});});it('create string tensor', () => {- const str_arr = ['text', 'more text', 'even more text'];- const tensor = new ov.Tensor(str_arr);- assert.deepStrictEqual(tensor.data, str_arr);+ const strArray = ['text', 'more text', 'even more text'];+ const tensor = new ov.Tensor(strArray);+ assert.deepStrictEqual(tensor.data, strArray);});it('create string tensor', () => {- const str_arr = ['text', 'more text', 'even more text'];- const tensor = new ov.Tensor(str_arr);- assert.deepStrictEqual(tensor.data, str_arr);+ const strArray = ['text', 'more text', 'even more text'];+ const tensor = new ov.Tensor(strArray);+ assert.deepStrictEqual(tensor.data, strArray);});it('string tensor - passed array does not contain string elements', () => {- const str_arr = ['text', true];- assert.throws(() => { new ov.Tensor(str_arr);},- /The array passed to create string tensor must contain only strings./- );+ const strArray = ['text', true];+ assert.throws(() => {+ new ov.Tensor(strArray);+ }, /The array passed to create string tensor must contain only strings./);});it('set string tensor data', () => {- const str_arr = ['H', 'e', 'l', 'l', 'o'];+ const strArray = ['H', 'e', 'l', 'l', 'o'];const tensor = new ov.Tensor(ov.element.string, [1, 1, 1, 5]);- tensor.data = str_arr;- assert.deepStrictEqual(tensor.data, str_arr);+ tensor.data = strArray;+ assert.deepStrictEqual(tensor.data, strArray);});it('test tensor getData()', () => {@@ -84,30 +122,27 @@ describe('ov.Tensor tests', () => {});it('test tensor.data setter - different element type throws', () => {- const float64_data = Float64Array.from([1, 2, 3] );+ const float64Data = Float64Array.from([1, 2, 3]);const tensor = new ov.Tensor(ov.element.f32, [1, 3]);assert.throws(() => {- tensor.data = float64_data;},- /Passed array must have the same size as the Tensor!/- );+ tensor.data = float64Data;+ }, /Passed array must have the same size as the Tensor!/);});it('test tensor.data setter - different element length throws', () => {- const float64_data = Float64Array.from([1, 2, 3] );+ const float64Data = Float64Array.from([1, 2, 3]);const tensor = new ov.Tensor(ov.element.f64, [1, 2]);assert.throws(() => {- tensor.data = float64_data;},- /Passed array must have the same size as the Tensor!/- );+ tensor.data = float64Data;+ }, /Passed array must have the same size as the Tensor!/);});it('test tensor.data setter', () => {const testString = 'test';const tensor = new ov.Tensor(ov.element.f64, [1, 2]);assert.throws(() => {- tensor.data = testString;},- /Passed argument must be TypedArray, or Array if the tensor type is string./- );+ tensor.data = testString;+ }, /Passed argument must be TypedArray, or Array/);});it('test tensor.data setter', () => {@@ -130,40 +165,45 @@ describe('ov.Tensor tests', () => {const buffer = new ArrayBuffer(size);const view = new Float32Array(buffer);view.set(data);- assert.throws( () => new ov.Tensor(ov.element.f32, shape, view),- {message: /Memory allocated using shape and element::type mismatch/});+ assert.throws(() => new ov.Tensor(ov.element.f32, shape, view), {+ message: /Memory allocated using shape and element::type mismatch/,+ });});it('third argument of a tensor cannot be an ArrayBuffer', () => {assert.throws(() => new ov.Tensor(ov.element.f32, shape, new ArrayBuffer(1234)),- {message: /Third argument of a tensor must be TypedArray./});+ { message: /Third argument of a tensor must be TypedArray./ },+ );});it('third argument of a tensor cannot be an array object', () => {- assert.throws(- () => new ov.Tensor(ov.element.f32, shape, [1, 2, 3, 4]),- {message: /Third argument of a tensor must be TypedArray./});+ assert.throws(() => new ov.Tensor(ov.element.f32, shape, [1, 2, 3, 4]), {+ message: /Third argument of a tensor must be TypedArray./,+ });});});describe('Tensor shape', () => {-it('ov::Shape from an array object', () => {const tensor = new ov.Tensor(ov.element.f32, [1, 3, 224, 224], data);assert.deepStrictEqual(tensor.getShape(), [1, 3, 224, 224]);});it('ov::Shape from an array object with floating point numbers', () => {- const tensor =- new ov.Tensor(ov.element.f32, [1, 3.0, 224.8, 224.4], data);+ const tensor = new ov.Tensor(+ ov.element.f32,+ [1, 3.0, 224.8, 224.4],+ data,+ );assert.deepStrictEqual(tensor.getShape(), [1, 3, 224, 224]);});it('array argument to create ov::Shape can only contain numbers', () => {assert.throws(() => new ov.Tensor(ov.element.f32, ['1', 3, 224, 224], data),- {message: /Passed array must contain only numbers/});+ { message: /Passed array must contain only numbers/ },+ );});it('ov::Shape from TypedArray -> Int32Array', () => {@@ -176,7 +216,7 @@ describe('ov.Tensor tests', () => {const shape = Float32Array.from([1, 224, 224, 3]);assert.throws(() => new ov.Tensor(ov.element.f32, shape, data),- /Passed argument must be an Int32Array or a Uint32Array./+ /Passed argument must be an Int32Array or a Uint32Array./,);});@@ -184,30 +224,27 @@ describe('ov.Tensor tests', () => {const shape = Int32Array.from([1, 224, 224, 3]);assert.throws(() => new ov.Tensor(ov.element.f32, shape.buffer, data),- /Passed argument must be of type Array or TypedArray./+ /Passed argument must be of type Array or TypedArray./,);});it('getShape() method does not accept parameters', () => {const tensor = new ov.Tensor(ov.element.f32, [1, 3, 224, 224], data);- assert.throws(- () => tensor.getShape(1, 2, 3),- { message: 'No parameters are allowed for the getShape() method.'}- );+ assert.throws(() => tensor.getShape(1, 2, 3), {+ message: 'No parameters are allowed for the getShape() method.',+ });});});describe('Tensor element type', () => {it('comparisons of ov.element to string', () => {params.forEach(([elemType, val]) => {-assert.strictEqual(elemType, val);});});it('comparisons of ov.element got from Tensor object', () => {params.forEach(([elemType, , data]) => {-const tensor = new ov.Tensor(elemType, shape, data);assert.strictEqual(tensor.getElementType(), elemType);});@@ -215,7 +252,6 @@ describe('ov.Tensor tests', () => {});describe('Tensor getSize', () => {-it('getSize returns the correct total number of elements', () => {const tensor = new ov.Tensor(ov.element.f32, shape, data);const expectedSize = shape.reduce((acc, dim) => acc * dim, 1);@@ -224,18 +260,16 @@ describe('ov.Tensor tests', () => {it('getSize should throw an error if arguments are provided', () => {const tensor = new ov.Tensor(ov.element.f32, shape, data);- assert.throws(- () => tensor.getSize(1),- { message: 'getSize() does not accept any arguments.' }- );+ assert.throws(() => tensor.getSize(1), {+ message: 'getSize() does not accept any arguments.',+ });});});describe('Tensor getSize for various shapes', () => {-- it('calculates size correctly for a common image data shape [3, 224, 224]', () => {+ it('calculates size for a common image data shape [3, 224, 224]', () => {const shape = [3, 224, 224];- const expectedSize = 3*224*224;+ const expectedSize = 3 * 224 * 224;const tensorData = new Float32Array(expectedSize).fill(0);const tensor = new ov.Tensor(ov.element.f32, shape, tensorData);assert.strictEqual(tensor.getSize(), expectedSize);diff --git a/src/bindings/js/node/tests/unit/utils.js b/src/bindings/js/node/tests/unit/utils.jsindex cf541a332b1..c2089e30b4c 100644--- a/src/bindings/js/node/tests/unit/utils.js+++ b/src/bindings/js/node/tests/unit/utils.js@@ -4,7 +4,10 @@const path = require('path');const fs = require('node:fs/promises');-const { downloadFile, checkIfPathExists } = require('../../scripts/download_runtime');+const {+ downloadFile,+ checkIfPathExists,+} = require('../../scripts/download_runtime');const modelDir = 'tests/unit/test_models/';const testModels = {@@ -25,7 +28,7 @@ module.exports = {testModels,};-function getModelPath(isFP16=false) {+function getModelPath(isFP16 = false) {const modelName = `test_model_fp${isFP16 ? 16 : 32}`;return {@@ -63,7 +66,8 @@ async function isModelAvailable(model) {const modelExists = await checkIfPathExists(modelPath);if (modelExists) return;- console.log('\n\nTestModel cannot be found.\nPlease run `npm run test_setup`.\n\n');+ console.log(+ '\n\nTestModel cannot be found.\nPlease run `npm run test_setup`.\n\n',+ );process.exit(1);-}