-
Notifications
You must be signed in to change notification settings - Fork 171
Open
Labels
Description
Problem description
Calling reset() from the appended snippet in test runs leads to
TypeError: Cannot set property crypto of #<Object> which has only a getter
at Tabris.<anonymous> ({project}/node_modules/tabris/tabris.min.js:1:253291)
at notifyCallback ({project}/node_modules/tabris/tabris.min.js:1:29169)
at Tabris.[notify] ({project}/node_modules/tabris/tabris.min.js:1:28112)
at Tabris.trigger ({project}/node_modules/tabris/tabris.min.js:1:27702)
at Tabris._init ({project}/node_modules/tabris/tabris.min.js:1:85906)
at reset ({project}/test/tabris-mock.ts:13:10)
at Object.<anonymous> ({project}/test/tabris-mock.ts:94:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module.m._compile ({project}/node_modules/ts-node/src/index.ts:858:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Object.require.extensions.<computed> [as .ts] ({project}/node_modules/ts-node/src/index.ts:861:12)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> ({project}/test/integration/build-info.spec.ts:2:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module.m._compile ({project}/node_modules/ts-node/src/index.ts:858:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Object.require.extensions.<computed> [as .ts] ({project}/node_modules/ts-node/src/index.ts:861:12)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.exports.requireOrImport ({project}/node_modules/mocha/lib/esm-utils.js:42:12)
at Object.exports.loadFilesAsync ({project}/node_modules/mocha/lib/esm-utils.js:55:34)
at Mocha.loadFilesAsync ({project}/node_modules/mocha/lib/mocha.js:473:19)
at singleRun ({project}/node_modules/mocha/lib/cli/run-helpers.js:125:15)
at exports.runMocha ({project}/node_modules/mocha/lib/cli/run-helpers.js:190:10)
at Object.exports.handler ({project}/node_modules/mocha/lib/cli/run.js:362:11)
at {project}/node_modules/yargs/build/index.cjs:443:71Expected behavior
No error, test runs succeeding.
Environment
- Tabris.js version: 3.9.0-dev.20230630 also tried with 3.9.0-dev.20240212
tabris._init is used in test runs, until now no issues in productive code noticed
Code snippet
import { tabris } from 'tabris';
import ClientMock from 'tabris/ClientMock';
const DEFAULT_APP_VERSION = '1.0.0';
const DEFAULT_DEVICE_ORIENTATION = 'portrait';
const DEFAULT_DEVICE_PLATFORM = 'Android';
const DEFAULT_DEVICE_MODEL = 'foo';
const DEFAULT_FILESYSTEM_PATH = 'path';
export function reset() {
const clientOptions = getDefaultMockClientOptions();
const clientMock = new ClientMock(clientOptions);
tabris._init(clientMock);
}
function getDefaultMockClientOptions() {
return {
'tabris.App': { ...getAppVersionOptions(DEFAULT_APP_VERSION) },
'tabris.Device': { ...getDeviceOptions() },
'tabris.FileSystem': { ...getFileSystemOptions(DEFAULT_FILESYSTEM_PATH) }
};
}
function getFileSystemOptions(filesDir: string) {
return {
filesDir,
readDir: (name: any) => {
if (typeof name === 'string') {
return Promise.resolve([]);
}
return Promise.reject('folder path should be a string');
},
writeFile: () => Promise.resolve(),
readFile: () => Promise.resolve()
};
}
function getDeviceOptions(
platform: string = DEFAULT_DEVICE_PLATFORM,
model: string = DEFAULT_DEVICE_MODEL,
orientation: string = DEFAULT_DEVICE_ORIENTATION
) {
return {
...getDeviceOrientationOptions(orientation),
...getDeviceModelOptions(model),
...getDevicePlatformOptions(platform)
};
}
function getDevicePlatformOptions(platform: string) {
return { platform };
}
function getDeviceModelOptions(model: string) {
return { model };
}
function getDeviceOrientationOptions(orientation: string) {
return { orientation };
}
function getAppVersionOptions(version: string) {
return { version };
}
reset();Reactions are currently unavailable