TestCafe runner.video is not a function at createTestCafe.then.then.remoteConnection - javascript

EDITED
I'm facing this issue while trying to create test videos using the TestCase Javascript API.
I'm working with testcafe version 0.22.0 and I already have the prerequisites the request in their documentation.
Basically, the issue is video function doesn't exist in my runner object.
https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/screenshots-and-videos.html#record-videos
createTestCafe('localhost', 1337, 1338)
.then(testcafe => {
runner = testcafe.createRunner();
return testcafe.createBrowserConnection();
})
.then(remoteConnection => {
// Outputs remoteConnection.url so that it can be visited from the remote browser.
runner
.video(artifactsPath, true)
.src(specsPath + '/run-animation.spec.ts')
.browsers(['chrome'])
.reporter('json')
.run()
.then(failedCount => {
console.log('Error: ', failedCount);
})
.catch(error => {
console.log('Error: ', error);
});
});

You are using the old TestCafe version. The 'Recording Video' feature appeared in a version older than 0.22.0.
The latest TestCafe version (1.1.2) exactly contains this feature.

Related

Implemating git push and pull with simple-git package in node.js

I am currently developing an online code editor. One of the features of the app is cloning or pulling a remote repository and the user also can push his project to the remote repository. Because the app has Github Oauth, with the token I can access private repos too. The cloning of any repo works perfectly. If I clone a repo first the pull and push work perfect too, but if I don't clone, they don't work at all. I have searched a lot on the internet, but I haven't found good examples so I can learn how to properly use this simple-git package.
Does anyone have implemented something similar or have worked with this package again and can share a snippet of code with implementing these 3 functionalities?
These are the functions that I have implemented so far.
//if the repo folder that the user selected exists then pull the changes from the remote else it
//clones the remote
function repo (req,res){
fs.exists(path.join(__dirname,currentpath,repo_fname),async exists => {
if(exists){
//git pull here
const git = simpleGit({ baseDir: path.join(__dirname,currentpath,repo_fname) });
User.findOne({git_user: req.body.git_username})
.exec(async(error , user) => {
await git.addConfig('user.email',user.git_email);
await git.addConfig('user.name',user.git_user);
})
git.addRemote(req.body.username, repolink);
await git.add('./*');
await git.commit("Updated"+ new Date());
await git.pull(req.body.username, req.body.branch)
.then(()=>{
console.log('Pulling Repo finished\n');
res.send({mess: "ok"});
})
.catch((err) => {
console.error('failed: ', err);
res.send({err : "The pulling of the repo failed.Please try again."});});
}else{
//git clone here
try{
fs.mkdirSync(path.join(__dirname,currentpath,repo_fname),{recursive:true});
const git = simpleGit({ baseDir: path.join(__dirname,currentpath,repo_fname) });
const options = ["--single-branch", "--branch" , req.body.branch,'--depth', '1'];
git.clone(repolink, path.join(__dirname,currentpath,repo_fname),options)
.then(() => {
console.log('Cloning Repo finished\n');
res.send({mess: "ok"});
})
.catch((err) => {
console.error('failed: ', err);
res.send({err : "The cloning of the repo failed.Please try again."});});
}catch{
let err= "Error with creating folder"+ folderpath;
console.log(err);
res.send({err: err});
}
}
});}
//pushes the local repo to the remote
async funcion pushrepo (req,res){
const git = simpleGit({ baseDir: path.join(__dirname,currentpath) });
User.findOne({git_user: req.body.git_username})
.exec(async(error , user) => {
awaitgit.addConfig('user.email',user.git_email);
await git.addConfig('user.name',user.git_user);
await git.add('./*');
await git.commit(req.body.commit_msg);
git.addRemote(req.body.username, req.body.repolink);
await git.push(req.body.username, req.body.branch,["--set-upstream","--force"])
.then(()=>{
console.log('Pushing to Repo finished\n');
res.send({mess: "ok"});
})
.catch((err) => {
console.error('failed: ', err);
res.send({err : "The push to the repo failed.Please try again."});
});
});
}

Enabling offline for firebase realtime database using Ionic app with capacitor

I am using ionic with firebase realtime database and capacitor 3. I intend to enable offline capabilities. I have built the app using ionic cap build and then opened in xcode. Then following url https://firebase.google.com/docs/database/ios/offline-capabilities I added the below code in AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
Database.database().isPersistenceEnabled = true
return true
}
Now to test i ran the app with wifi on and got the data from firebase db. after this i killed the app and turned off wifi. However, on launching the app it does not load the data.
Is there anything else i am missing here?
my key pod file has:
target 'App' do
capacitor_pods
# Add your Pods here
pod 'FirebaseCore', '7.11.0' # Add this line
pod 'Firebase/Database', '7.11.0' # Add this line
end
Below is my code that does not work and expected to:
getSeedConfig(){
return new Promise((resolve, reject) =>{
const doc = ref(this.db, 'config/seed');
get(doc).then((snapshot) => {
if (snapshot.exists()) {
resolve(snapshot.val())
} else {
resolve(null)
}
}).catch((error) => {
reject(error)
});
})
}
When using a modern API in JavaScript there are not many cases where you need to return a custom promise anymore.
As far as I can tell this code that you now have:
getSeedConfig(){
return new Promise((resolve, reject) =>{
const doc = ref(this.db, 'config/seed');
get(doc).then((snapshot) => {
if (snapshot.exists()) {
resolve(snapshot.val())
} else {
resolve(null)
}
}).catch((error) => {
reject(error)
});
})
}
Can be shortened to:
getSeedConfig(){
const doc = ref(this.db, 'config/seed');
return get(doc).then((snapshot) => {
return snapshot.val(); // 👈 returns null when the snapshot does not exist
})
}

Solve issue: Checking is logged

I'm testing whatsapp bot with node js and venom-bot and the code stays processing Cheking is logged... and never stops.
CMD - Print
In the first attemp, the code runs okay, showing me Whatsapp's QRCode, however,once I scanned it, shut down the program and start again, the code falls in line Checking is logged.
It's my code in index.js file:
// Supports ES6
// import { create, Whatsapp } from 'venom-bot';
const venom = require('venom-bot');
venom
.create('test-user')
.then((client) => start(client))
.catch((error) => { console.log(error); });
function start(client) {
client.onMessage((message) => {
if (message.body === 'Hi' && message.isGroupMsg === false) {
client
.sendText(message.from, 'Welcome Venom 🕷')
.then((result) => {
console.log('Result: ', result); //return object success
})
.catch((error) => {
console.error('Error when sending: ', error); //return object error
});
}
});
}
Issue was solved in an issue in Venom Git Hub' Repo: https://github.com/orkestral/venom/issues/782

Javascript- Web Bluetooth API GATT Error: Not supported

This question might have been asked by many people, but I have no luck to get answer from researching.
My ultimately plan is running a web app with Web Bluetooth API in smartphone with FLIC button to control audios to play. One click, play one audio.
I'm testing the program in my MAC laptop with my iPhoneX first, because I'm thinking if I can get both of them connected, then when I run the web app in smartphone, then I can connect to the FLIC button.
However, I got this error.
Something went wrong. NotSupportedError: GATT Error: Not supported.
Am I missing something? I saw someone mentioned iPhone cannot connect Latop, hopefully this is not true
Below is the code:
$("#bluetooth").on("click", function(){
const controlServiceUUID = '00001805-0000-1000-8000-00805f9b34fb'; // Full UUID
const commandCharacteristicUUID = '00002a0f-0000-1000-8000-00805f9b34fb'; //
var myCharacteristic;
navigator.bluetooth.requestDevice({
acceptAllDevices: true,
optionalServices: [controlServiceUUID]
})
.then(device => {
console.log("Got device name: ", device.name);
console.log("id: ", device.id);
return device.gatt.connect();
console.log("Here");
})
.then(server => {
serverInstance = server;
console.log("Getting PrimaryService");
return server.getPrimaryService(controlServiceUUID);
})
.then(service => {
console.log("Getting Characteristic");
return service.getCharacteristic(commandCharacteristicUUID);
})
.then(characteristic => {
// 0x01,3,0x02,0x03,0x01
myCharacteristic = characteristic;
return myCharacteristic.startNotifications().then(_ => {
log('Notifications started');
myCharacteristic.addEventListener('characteristicvaluechanged', test);
});
})
.catch(function(error) {
console.log("Something went wrong. " + error);
});
function test(event) {
if (myCharacteristic) {
myCharacteristic.startNotifications()
.then(_ => {
console.log("Notification stopped!");
})
.catch(error => {
console.log("Argh!" + error);
});
}
}
});
Web Bluetooth API is only available on ChromeOS and Android 6 or later with flag option.
(https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API)
Different platforms are at different points in implementation. I have been using this repo for updates on the status of the API:
WebBluetoothCG/web-bluetooth
Note the lack of support for ios
Not sure if this fixes your problem (i'm working on muse eeg), but one "hack" to get rid of this error is to wait some time (e.g. 500ms) after each characteristic write. Most platforms don't support write responses yet and writing multiple commands in parallel will cause this error.
https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md
Is your command characteristic UUID filled in incorrectly? Try replacing it with one that can be written?
const controlServiceUUID = 0xfff0; // Full UUID
const commandCharacteristicUUID = 0xfff4; //

Headless Chrome output javascript errors

Is there any way to output js errors using headless chrome?
For example, this site https://labs.observepoint.com/ has this js error: Uncaught SyntaxError: Unexpected token ! and I need to log it in headless chrome
This is what I tried:
Start headless chrome with: google-chrome --headless --enable-logging --v=1 --remote-debugging-port=9222
And then run this code:
const CDP = require('chrome-remote-interface');
CDP((client) => {
// extract domains
const {Network, Page} = client;
// setup handlers
Network.requestWillBeSent((params) => {
console.log(params.request.url);
});
Page.loadEventFired(() => {
client.close();
});
// enable events then start!
Promise.all([
Network.enable(),
Page.enable()
]).then(() => {
return Page.navigate({url: 'https://labs.observepoint.com/'});
}).catch((err) => {
console.error(err);
client.close();
});
}).on('error', (err) => {
// cannot connect to the remote endpoint
console.error(err);
});
But I don't know where the browser errors are logged
Try to use --enable-logging=v=1 in your command line. More information you can find here: enable-logging.

Categories