where({keypath:value, ...}) notation do not work - dexie

I'm using the official page example from Table.where() documentation page:
db.friends.where({name: "David", age: 43}).first(friend => {
console.log("Found David, 43: " + JSON.stringify(friend));
}).catch(error => {
console.error(error.stack || error);
});
It simply doesn't work. It can't find the "first" method.
It returns a WhereClause.
it should return a Collection.

It applies to version 2.x only. Documentation mentions that but only in a comment. I updated the docs now to be more clear.
I can recommend to start using dexie#^2.0.0-beta.10 as it has been out for a while.
npm i dexie#next --save

Related

How do i fix DEPRECATION: The matcher factory for "toHaveBeenTriggeredOnAndWith"?

Can anyone tell me what needs to be changed this test?
it('Should update settings of bar', () => {
const newSettings = {
dataset: [
{
data: [{
name: 'Category A',
value: 373,
color: '#1D5F8A',
id: 1
}],
name: ''
}
]
};
barObj.updated(newSettings);
const dataLength = barObj.settings.dataset[0].data.length;
expect(dataLength).toEqual(1);
});
I am getting this error from Jasmine and if i follow the link https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#matchers-cet i dont see exactly what i would need to change?
ERROR: 'DEPRECATION: The matcher factory for "toHaveBeenTriggeredOnAndWith" accepts custom equality testers, but this parameter will no longer be passed in a future release. See https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#matchers-cet for details. (in spec: Bar API Should update settings of bar)
I also cant find a lot of information about this message. I also dont have any custom equality matchers in the system. https://jasmine.github.io/tutorials/custom_equality
Try to update karma-jasmine package. It helped me.
I had this problem using "#metahub/karma-jasmine-jquery". You can modify the bundle in place and remove the second parameter from the `` toHaveBeenTriggeredOnAndWith" function. Or copy the module somewhere, uninstall "#metahub/karma-jasmine-jquery" and install the modified module: npm install ./#metahub/karma-jasmine-jquery

i get error 'FileProvider' of undefined using record function with nativescript-videorecorder

i need help.
TypeError: Cannot read property 'FileProvider' of undefined
I get that error when i try to record.
Code:
const options: VideoRecorderOptions = {
hd: true,
saveToGallery: true
}
const videorecorder = new VideoRecorder(options)
videorecorder.record().then((data) => {
console.log(data.file)
}).catch((err) => {
console.log(err)
})
It seems to be Android X compatibility issue, the plugin author will have to update the plugin to support {N} 6.x and later.
android.support.v4.content.FileProvider is now androidx.core.content.FileProvider. You may update the code and compile it locally as a workaround.

WebdriverIO waitUntil example is not working

I am trying to use Webdriverio v5 and I have problems to run the example for waitUntil https://webdriver.io/docs/api/browser/waitUntil.html
it('should wait until text has changed', () => {
browser.waitUntil(() => {
return $('#someText').getText() === 'I am now different'
}, 5000, 'expected text to be different after 5s');
});
the error is saying
Type 'boolean' is not assignable to type 'Promise<boolean>'
anyone else is facing the same problem?
or how to fix it?
while in v4 everything works as expected
It looks like you're using typescript in your tests. Make sure you've gone through the entire typescript/webdriverio setup: https://webdriver.io/docs/typescript.html
In this case, I think you need to add wdio-sync to your compilerOptions types setting.
"compilerOptions": {
"types": ["node", "#wdio/sync"]
}

Unit testing: getText is not a function

I'm new to unit testing and I'm trying to select an ID to select its text and check if it equals 'Inbox'. I'm getting a
TypeError in "User visits Quick Add Task starts with a blank task" elem.getText is not a function
and I don't understand why.
Test source code here.
describe('User visits Quick Add Task', () => {
it('starts with a blank task', () => {
browser.url('http://localhost:8080/');
const elem = $('#inbox-clickable');
console.log(elem.getText());
assert.equal(elem.getText(), 'Inbox');
})
});
For me the solution to a very similar problem was adding the missing #wdio/sync package to my package.json.
I already had previously added sync: true, to my wdio.conf.js and remove all async and await from my testing code.

Removing console.log from React Native app

Should you remove the console.log() calls before deploying a React Native app to the stores? Are there some performance or other issues that exist if the console.log() calls are kept in the code?
Is there a way to remove the logs with some task runner (in a similar fashion to web-related task runners like Grunt or Gulp)? We still want them during our development/debugging/testing phase but not on production.
Well, you can always do something like:
if (!__DEV__) {
console.log = () => {};
}
So every console.log would be invalidated as soon as __DEV__ is not true.
Babel transpiler can remove console statements for you with the following plugin:
npm i babel-plugin-transform-remove-console --save-dev
Edit .babelrc:
{
"env": {
"production": {
"plugins": ["transform-remove-console"]
}
}
}
And console statements are stripped out of your code.
source: https://hashnode.com/post/remove-consolelog-statements-in-production-in-react-react-native-apps-cj2rx8yj7003s2253er5a9ovw
believe best practice is to wrap your debug code in statements such as...
if(__DEV__){
console.log();
}
This way, it only runs when you're running within the packager or emulator. More info here...
https://facebook.github.io/react-native/docs/performance#using-consolelog-statements
I know this question has already been answered, but just wanted to add my own two-bits. Returning null instead of {} is marginally faster since we don't need to create and allocate an empty object in memory.
if (!__DEV__)
{
console.log = () => null
}
This is obviously extremely minimal but you can see the results below
// return empty object
console.log = () => {}
console.time()
for (var i=0; i<1000000; i++) console.log()
console.timeEnd()
// returning null
console.log = () => null
console.time()
for (var i=0; i<1000000; i++) console.log()
console.timeEnd()
Although it is more pronounced when tested elsewhere:
Honestly, in the real world this probably will have no significant benefit just thought I would share.
I tried it using babel-plugin-transform-remove-console but the above solutions didn't work for me .
If someone's also trying to do it using babel-plugin-transform-remove-console can use this one.
npm i babel-plugin-transform-remove-console --save-dev
Edit babel.config.js
module.exports = (api) => {
const babelEnv = api.env();
const plugins = [];
if (babelEnv !== 'development') {
plugins.push(['transform-remove-console']);
}
return {
presets: ['module:metro-react-native-babel-preset'],
plugins,
};
};
I have found the following to be a good option as there is no need to log even if __DEV__ === true, if you are not also remote debugging.
In fact I have found certain versions of RN/JavaScriptCore/etc to come to a near halt when logging (even just strings) which is not the case with Chrome's V8 engine.
// only true if remote debugging
const debuggingIsEnabled = (typeof atob !== 'undefined');
if (!debuggingIsEnabled) {
console.log = () => {};
}
Check if in remote JS debugging is enabled
Using Sentry for tracking exceptions automatically disables console.log in production, but also uses it for tracking logs from device. So you can see latest logs in sentry exception details (breadcrumbs).

Resources