allure.createAttachment exception error - Cannot read property 'currentStep' of undefined - protractor

I can successfully add screenshots to allure reports, but i get the following exception error:
error:
TypeError: Cannot read property 'currentStep' of undefined
at Allure.addAttachment (/Users//xxx/xxx/xxx/node_modules/allure-js-commons/index.js:86:45)
at Allure.createAttachment (/Users/xxx/xxx/xxx/node_modules/allure-js-commons/runtime.js:48:29)
at /Users/xxx/xxx/xxx/lib/class/class-name.js:30:20
at process._tickCallback (internal/process/next_tick.js:68:7)
class:
browser.takeScreenshot().then(function (png) {
allure.createAttachment(title, new Buffer(png, 'base64'));
}).catch((error: any) => console.log(error));

const allure = require('mocha-allure-reporter');
allure is a global identifier, injected by reporter to your code.
Add the following line to the top of your file to tell Typescript about it
declare const allure: any;

I think createAttachment requires a callback function and not a buffer being passed directly.
Can you try changing your code to reflect the following
browser.takeScreenshot().then(function (png) {
allure.createAttachment('Screenshot', function () {
return new Buffer(png, 'base64')
}, 'image/png')()
}).catch((error: any) => console.log(error));

Related

vitest + msw / testing reactQuery (axios) hooks using renderHook / unable to avoid error logging from test suite

Using a custom logger as follow for our test suite :
export const queryClient = new QueryClient({
logger: {
log: console.log,
warn: console.warn,
error: () => {}
}
});
Mocking errors as follow within msw :
rest.get('/some/api/route', (_req, res, ctx) => {
return res.once(ctx.status(500), ctx.json({ errorMessage: 'some error' }));
})
We override the handlers for errors :
it("should return error", () => {
server.use(...errorHandlers);
const { result } = renderHook(() =>
query({
url: '/some/api/routes',
options: { retry: false }
})
);
...some assertions
});
Out tests are ok, but the network errors are still appearing in the console when running the test suite (the display is thrashed) :
Error: Request failed with status code 500
at createError (.../node_modules/axios/lib/core/createError.js:16:15)
at settle (.../node_modules/axios/lib/core/settle.js:17:12)
at XMLHttpRequestOverride.onloadend (.../node_modules/axios/lib/ad
... super long logging ...
Such non blocking issue is tackled in other projects using jest as the custom queryClient logger does the job; it seems that it behaves differently using vitest. Does anyone knows which part is the culprit in that context ? What should be done ?
passing a custom logger to the QueryClient is a feature that was introduced in v4.
For v3, you need to call setLogger, which is exported from react-query:
https://react-query-v3.tanstack.com/reference/setLogger
import { setLogger } from 'react-query'
setLogger({
log: console.log,
warn: console.warn,
error: () => {}
})

why am i getting TypeError: Cannot read property 'getText' of undefined error even though my web element reference is correct?

I'm getting an error returned when i run a protractor test.
Here is the reference to the webelement in the directories.page.js file:
get importErrorsList(){
return element.all(by.css('[ng-if="error.error.detailMessage"]'));
}
Here is a screenshot of the webelement and it's source info:
And finally here is the step that i am using to reference the webelement, which is returning the error:
Then(/^The list of import errors contains this error message: "([^"]*)"$/, function (errorText, callback) {
browser.wait(EC.visibilityOf(importPageObj.alertMsg), timeouts.EC_TIMEOUT).then(function(){
browser.wait(() => {
//the next line causes the error
expect(directoriesPageObj.importErrorsList.getText()).to.eventually.contain(errorText).and.notify(callback);
}, timeouts.EC_TIMEOUT).then(() => {
browser.wait(EC.and(EC.visibilityOf(importPageObj.headerDropDownInWebView), EC.elementToBeClickable(importPageObj.headerDropDownInWebView)), timeouts.EC_TIMEOUT).then(() => {
callback();
});
});
});
});
could anyone help me figure out why this isn't working?
you did not initialise directoriesPageObj. So, before using it you should make:
const directoriesPageObj = new DirectoriesPageObj()
and after it you can use directoriesPageObj variable. For example:
Then(/^The list of import errors contains this error message: "([^"]*)"$/, function (errorText, callback) {
browser.wait(EC.visibilityOf(importPageObj.alertMsg), timeouts.EC_TIMEOUT).then(function(){
browser.wait(() => {
const directoriesPageObj = new DirectoriesPageObj();
expect(directoriesPageObj.importErrorsList.getText()).to.eventually.contain(errorText).and.notify(callback);
}, timeouts.EC_TIMEOUT).then(() => {
browser.wait(EC.and(EC.visibilityOf(importPageObj.headerDropDownInWebView), EC.elementToBeClickable(importPageObj.headerDropDownInWebView)), timeouts.EC_TIMEOUT).then(() => {
callback();
});
});
});
});

Cannot read property 'logInWithReadPermissions' of undefined, but there is LoginManager

I am using react-native (0.55.3) and react-native-fbsdk (0.8.0) to enable Facebook auth.
import React, { Component } from 'react';
import { AccessToken, LoginManager } from 'react-native-fbsdk';
import firebase from 'react-native-firebase';
...
// In the middle of a function
console.log(LoginManager);
const test = await LoginManager.logInWithReadPermissions(['public_profile']);
console.log(test);
LoginManager.logInWithReadPermissions(['public_profile'])
.then((result) => {
console.log(result);
})
.catch((err) => {
console.log(err);
})
// The following is the result from console.log(LoginManager)
getDefaultAudience: ƒ getDefaultAudience()
getLoginBehavior: ƒ getLoginBehavior()
logInWithPublishPermissions: ƒ logInWithPublishPermissions(permissions)
logInWithReadPermissions: ƒ logInWithReadPermissions(permissions)
logOut: ƒ logOut()
setDefaultAudience: ƒ setDefaultAudience(defaultAudience)
setLoginBehavior: ƒ setLoginBehavior(loginBehavior)
__proto__: Object
// Result from console.log(test); or console.log(err);
TypeError: Cannot read property 'logInWithReadPermissions' of undefined
One weird thing is that I know that LoginManager is defined, and I see that it has logInWithReadPermissions function. Whenever I try to use the function, however, it says that LoginManager is undefined, and I cannot use it.
Is there anybody who encountered same / similar issue?
Had the same issue on ios. For me these steps works:
react-native link react-native-fbsdk
Libraries > RCTFBSDK.xcodeproj > Build Settings > Framework Search Paths > $(HOME)/Documents/FacebookSDK (recursive)

sails helpers and machine spec

I upgrade sails to the #^1.0.0 version and while I'm developing an API, I wanted to use a Service but the Sails document advice to use Helper now. And I don't realy use to work with the new way to discripe helper, build script or actions.
And all the try I have mad wasn't successful.
In the following exemple..
Here is my controller call:
var ob = await ails.helpers.testy('sayHello');
res.json({ob:ob});
helper
module.exports = {
friendlyName: 'Testy',
description: 'Testy something.',
inputs: {
bla: {
type: 'string'
}
},
exits: {
success: {
}
},
fn: async function (inputs, exits) {
console.log({blabla:inputs.bla})
if(!inputs.bla) return exits.error(new Error('text not found'));
var h = "Hello "+ inputs.bla;
// All done.
return exits.success(h);
}
};
I'm getting this error
error: A hook (`helpers`) failed to load!
error:
error: Attempted to `require('*-serv\api\helpers\testy.js')`, but an error occurred:
--
D:\*-serv\api\helpers\testy.js:28
fn: async function (inputs, exits) {
^^^^^^^^
SyntaxError: Unexpected token function.......
and if I remove the "async" and the "await" form the Controller, the ob object return null and I'm having this error
WARNING: A function that was initially called over 15 seconds
ago has still not actually been executed. Any chance the
source code is missing an "await"?
To assist you in hunting this down, here is a stack trace:
```
at Object.signup [as auth/signup] (D:\*-serv\api\controllers\AuthController.js:106:26)
The first guy from the comments is right.
After removing async from fn: async function (inputs, exists) {}; you need to setup sync: true which is false by default. It is described at helpers doc page at Synchronous helpers section.
So your code should look like this
module.exports = {
friendlyName: 'Testy',
description: 'Testy something.',
sync: true, // Here is essential part
inputs: {
bla: {
type: 'string'
}
},
exits: {
success: {
}
},
fn: function (inputs, exits) {
console.log({blabla:inputs.bla})
if(!inputs.bla) return exits.error(new Error('text not found'));
var h = "Hello "+ inputs.bla;
// All done.
return exits.success(h);
}
};
From the another side, you have a problem with async/await. The top most reason for this are
Not supported Node.js version - check that you current version support it
If you use sails-hook-babel or another Babel related solution, you may miss required plugin for async/await processing

CollectionFS with mongo update command in Meteor.js

In my meteor.js application, I am trying to update a group's picture by using CollectionFS.
var groupimage = Images.insert(file);
Groups.update(groupId, {$set: { photo: groupimage }}, function(error) {
if (error) {
// display the error to the user
throwError(error.reason);
} else {
console.log('mongo document new');
console.log(Groups.findOne({_id:groupId}));
}
});
This does not work, it gives this error:
Exception in delivering result of invoking '/groups/update': ReferenceError: throwError is not defined
at http://localhost:3000/client/views/groups/editgroup/editgroupgeneral/editgr…dropzoneeditgroupgeneral.js?a1c6bb6d6c464c579ca4a82ca9f92775df17f5c5:39:21
at wrappedCallback (http://localhost:3000/packages/mongo-livedata.js?9213dc77ff40001575341a02827a8f1ed3200d98:531:9)
at null._callback (http://localhost:3000/packages/meteor.js?47d1d2b71177463dc159606cf930e44b9e3337f6:831:22)
at _.extend._maybeInvokeCallback (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:3802:12)
at _.extend.receiveResult (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:3822:10)
at _.extend._livedata_result (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:4831:9)
at onMessage (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:3667:12)
at http://localhost:3000/packages/livedata.js? 32d6f3870045baedecfa7c0d90861ead2810da37:2710:11
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
But when I insert instead of update, everything is working perfectly. This works.
var groupimage = Images.insert(file);
Groups.insert({
name: 'My Group',
photo: groupimage
});
What is the problem with my update? Thank you.
Edit
Exception in delivering result of invoking '/groups/update': Error
at http://localhost:3000/client/views/groups/editgroup/editgroupgeneral/editgr…dropzoneeditgroupgeneral.js?c24e8998d12b9aaa84912c2e87ec327e47277070:39:27
at wrappedCallback (http://localhost:3000/packages/mongo-livedata.js?9213dc77ff40001575341a02827a8f1ed3200d98:531:9)
at null._callback (http://localhost:3000/packages/meteor.js?47d1d2b71177463dc159606cf930e44b9e3337f6:831:22)
at _.extend._maybeInvokeCallback (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:3802:12)
at _.extend.receiveResult (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:3822:10)
at _.extend._livedata_result (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:4831:9)
at onMessage (http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:3667:12)
at http://localhost:3000/packages/livedata.js?32d6f3870045baedecfa7c0d90861ead2810da37:2710:11
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
Edit 2
errorClassdetails: undefinederror: 409errorType: "Meteor.Error"message: "MongoError: not okForStorage [409]"reason: "MongoError: not okForStorage"stack: (...)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: ""prototype: Object__proto__: function Empty() {}<function scope>set stack: function () { [native code] }__proto__: Middle
You should maybe use Meteor's error method instead:
throw new Meteor.Error(500, error.reason);