detox[3338] DEBUG: [APP_STATUS] Failed to execute the current status query - expo

I try to add detox to my expo application, everthing seams to work fine, but when I try to run the test I get following error message.
detox[3338] DEBUG: [APP_STATUS] Failed to execute the current status query.
firstTest.e2e.ts
const { reloadApp } = require('detox-expo-helpers');
describe('Example', () => {
beforeAll(async () => {
await reloadApp({
permissions: {
location: 'always',
userTracking: 'YES'
}
})
});
it('test', async () => {
await expect(element(by.id('settings'))).toBeVisible()
await element(by.id('settings')).tap()
console.log('success')
})
})
At first I start the expo server with yarn expo start --ios and then run the detox test with yarn detox test -c ios --loglevel trace. The app will be installed and loaded but stucks at the error message. Did any one has an solution?

Related

Puppeteer-core on the aws-lambda docker image Error: Target closed

I have been working with puppeteer-core on the aws-lambda docker image for a while but I have encountered recently a problem while running it locally.
It is a known old error "Protocol Error: Target closed", but I suddenly encountered the last few days.
I tried many solutions suggested on the threads like this one but so far I haven't been successful.
This is an easy to run simplified version of the code GitHub but I will write it down here too:
async function launchBrowser() {
try {
const puppeteer = require('puppeteer-core');
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--no-zygote',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--single-process',
],
headless: true,
ignoreHTTPSErrors: true,
executablePath: '/usr/bin/chromium-browser',
});
return browser;
} catch (error) {
console.log("error",error);
return launchBrowser();
}
}
async function lambdaHandler(event, context) {
let result = null;
console.info(`EVENT ${JSON.stringify(event, null, 2)}`);
const browser = await launchBrowser();
console.info('browser launched');
try{
console.log(await browser.version());
const page = await browser.newPage();
await page.goto(event.url);
result = await page.title();
console.info("Title",result);
}
catch(error){
console.log(error)
}
return result;
}
module.exports = { handler: lambdaHandler };
The docker file:
FROM public.ecr.aws/lambda/nodejs:14
RUN yum install -y amazon-linux-extras
RUN amazon-linux-extras install epel -y
RUN yum install -y chromium
RUN npm install puppeteer-core
COPY src/* ${LAMBDA_TASK_ROOT}
CMD [ "app.handler" ]
It gets stuck on browser.version() and sends that error.
The confusing thing is that when I deployed the code on AWS I didn't have the same issue so I couldn't identify the origin of this sudden change and why the errors are very inconsistent.
I want to also specify that I am working on MacOS Monterey with apple M1.
So if anyone can enlighten that would be very helpful.

Running Unit and automation UI tests in one place in Jenkins and receive such Error: Failed to launch the browser process

For now we are execute unit tests together with UI automation and for now unit tests is passing OK, but ui automation receive Error: Failed to launch the browser process!
for now we have Jenkins file for both tests templates
stage('Build npm env and Execute AutomationTests'){
steps {
executeDocker(dockerImage: 'docker.wdf.sap.corp:50000/buildkite/puppeteer:latest', dockerWorkspace: '/home/piper'){
sh 'npm install'
sh 'npm update -g'
sh 'npx browserslist#latest --update-db'
}
}
}
stage('Update Build Badge'){
steps {
script {
def userIdCause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
def userId = userIdCause[0].userId
gitCommit = sh(returnStdout: true, script: 'git rev-parse --short=8 HEAD').trim()
manager.addShortText('User: ' + userId + ' , Commit Sha: ' + gitCommit , "grey", "transparent", "0px", "white")
}
}
}
stage('Build UI Application and Execute UnitTests'){
steps {
executeDocker(dockerImage: 'node:14-stretch', dockerWorkspace: '/home/piper'){
sh 'npm install'
sh 'npm run build-dev'
sh 'npm run test'
stash name: "build", includes: 'dist/**, coverage/**'
}
}
}
also we have separate config files
this one for unit tests
module.exports = {
preset: "#vue/cli-plugin-unit-jest",
collectCoverage: true,
collectCoverageFrom: [
"src/**/*.{js,vue}",
"!src/main.js", // No need to cover bootstrap file
],
}
and this is config file for ui automation
module.exports = {
preset: "#vue/cli-plugin-unit-jest",
collectCoverage: true,
collectCoverageFrom: [
"src/**/*.{js,vue}",
"!src/main.js", // No need to cover bootstrap file
],
}
and setup file for ui automation
import puppeteer from "puppeteer"
jest.setTimeout(60000)
beforeAll(async () => {
global.browser = await puppeteer.launch({
headless: true,
slowMo: 0,
args: ["--disable-setuid-sandbox", "--no-sandbox"],
})
})
afterAll(() => {
global.browser.close()
})

How to set up pm2 in digital ocean cloud server for MERN Stack?

I able to set up the pm2 successfully with my MERN Stack application, but when I tried to run pm2 start server.js and it shows status online but I was not able to access my MERN stack application in the browser, but when I run my application without using pm2 npm run dev with Nodemon everything was working fine. Below is my server.js file
const express = require('express');
const mongoose = require('mongoose');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const cors = require('cors');
require('dotenv').config();
const config = require('config');
const path = require('path');
const devPort = 8080;
// Setup express app
const app = express();
app.use(cors());
app.options('*', cors());
app.use(express.json());
app.use(morgan('combined'));
app.use(bodyParser.urlencoded({ extended: true }));
mongoose.Promise = global.Promise;
const db = config.get('MONGODB_URI');
mongoose.connect(db, {
useUnifiedTopology: true,
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false
});
mongoose.connection
.once('open', () => console.log('Database connected!'))
.on('error', error => console.log('Could not connect', error));
/*route/api/file is here*/
app.use('/api/user', require('./route/api/user'));
//server static assets in production
if (process.env.NODE_ENV === 'production') {
//set static folder
app.user(express.static('client/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.htm'));
});
}
app.listen(process.env.PORT || devPort, () =>
console.log(`Node JS is running on port ${devPort}`)
);
here is an image of pm2 server.js online in the terminal but I could not access it.
I wondered, is it the problem with the server.js file, please give suggestions.
Thank you for your help.
Setup pm2 config
cd to project folder
Create ecosystem.config.js file for pm2 with the following config
module.exports = {
apps : [{
name : 'APPNAME',
script : './index.js',
env: {
NODE_ENV: 'development'
},
env_production : {
NODE_ENV: 'production'
}
}],
};
Start app's process using pm2
For production : pm2 start --env production
For development : pm2 start --env development
Some basic pm2 commands
Stop App : pm2 stop APPNAME
Start App : pm2 start APPNAME
Monitor App : pm2 monit APPNAME
Delete App : pm2 delete APPNAME
Show list of running pm2 processes : pm2 list
Hope this helps!

newman execution throwing TypeError: newman.run is not a function

I have newman 3.9.3 version installed on my ubuntu box. Want to execute multiple collections from a folder but executing js file through me wired error saying
TypeError: newman.run is not a function.
Here is my execution script. Any help will be appreciated.
#!/usr/bin/env node
var newman = require(process.env.NVM_BIN+'/newman');
var fs = require('fs');
fs.readdir('./collections', function (err, files) {
if (err) { throw err; }
files = files.filter(function (file) {
return (file.substr(-5) === '.json');
});
// now wer iterate on each file name and call newman.run using each file name
files.forEach(function (file) {
newman.run({
environment: require(`${__dirname}/live.postmane_environment.json`),
collection: require(`${__dirname}/collections/${file}`),
reporters: ['cli']
}, function (err) {
console.info(`${file}: ${err ? err.name : 'ok'}!`);
});
});
});
Following is the exact error.
/app/postman/execute:15
newman.run({
^
TypeError: newman.run is not a function
at /app/postman/execute:15:16
at Array.forEach (native)
at /app/postman/execute:14:11
at FSReqWrap.oncomplete (fs.js:123:15)
For the time being, I've solved this problem by using bash script to run all of my collections available in a folder. that has done the job. but originally i could not understand why "run" is not available for "newman" object.
I was getting the same error message and solved installing the nodejs package:
npm install --save newman
Basically, when you make the bin as reference the nodejs doesnt know how to run:
Instead of:
var newman = require(process.env.NVM_BIN+'/newman');
Should be:
var newman = require('newman');

Truffle error: Error: VM Exception while processing transaction: revert

I am using truffle:
truffle(development)> var hw
undefined
truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;});
undefined
truffle(development)> hw.SayHello.call()
i am getting below error in Truffle
***Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:41484:16)
at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:328866:36
at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:324536:9
at XMLHttpRequest.request.onreadystatechange (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:327565:7)
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176407:18)
at XMLHttpRequest._setReadyState (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176697:12)
at XMLHttpRequest._onHttpResponseEnd (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176852:12)
at IncomingMessage.<anonymous> (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176812:24)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7) ***
1) My HelloWorld.sol
`
pragma solidity ^0.4.8;
contract HelloWorld {
function SayHello() public returns (string) {
return ("SomeHello");
}
}
2) My 2_deploy_contracts.js
var ConvertLib = artifacts.require("./ConvertLib.sol");
var MetaCoin = artifacts.require("./MetaCoin.sol");
var HelloWorld = artifacts.require("./HelloWorld.sol");
var second = artifacts.require("./second.sol");
module.exports = function(deployer) {
deployer.deploy(ConvertLib);
deployer.link(ConvertLib, MetaCoin);
deployer.deploy(MetaCoin);
deployer.deploy(HelloWorld);
deployer.deploy(second);
};
3) My truffle.js
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
Please let me know how can I fix above error ?
`
I just ran your example and it worked fine. The only change I made was I removed the other smart contracts from 2_deploy_contracts that aren't used. Make sure you are running the compile and migrate commands and testrpc is running before starting the truffle console. Also, just in case you're running on Windows, rename truffle.js to truffle-config.js
$ truffle compile
Compiling .\contracts\HelloWorld.sol...
Writing artifacts to .\build\contracts
$ truffle migrate
Using network 'development'.
Running migration: 2_deploy_contracts.js
Deploying HelloWorld...
... 0xef7e895758805a3c3c9aaed7dc7c97fe7b2278b0c0d6ee8105192183a86188c9
HelloWorld: 0x54329ff919efda7920408084590d7480a6c88243
Saving successful migration to network...
... 0x0954625bf66275469c9475ca21f5db20bc4667efb716c5e19bfd98a9553f4a83
Saving artifacts...
$ truffle console
truffle(development)> var hw
undefined
truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;});
undefined
truffle(development)> hw.SayHello.call()
'SomeHello'
truffle(development)>
2_deploy_contracts.js
var HelloWorld = artifacts.require("./HelloWorld.sol");
module.exports = function(deployer) { deployer.deploy(HelloWorld); };