Detox/Jest Test suite failed to run TypeError: Class extends value #<Object> is not a constructor or null - react-native

I'm trying to integrate some e2e tests into my react native (expo ejected) mobile project. I'm following the instructions found on the detox Getting Started page. I'm able to successfully build my project, but everytime I attempt the detox test command:
detox test --configuration ios --loglevel trace
I get the following error:
FAIL e2e/firstTest.e2e.jsrun...
● Test suite failed to run
TypeError: Class extends value #<Object> is not a constructor or null
at Object.<anonymous> (../node_modules/detox/runners/jest-circus/environment.js:24:38)
at Object.newLoader (../node_modules/pirates/lib/index.js:141:7)
at Object.<anonymous> (../node_modules/detox/runners/jest-circus/index.js:4:32)
09:07:59.324 detox[21032] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' e2e
I have a fairly simple out-of-the-box configuration of detox and jest:
package.json
...
"detox": "^19.6.2"
"jest": "^27.0.0",
"jest-circus": "^27.5.1",
...
./e2e/config.json
{
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 120000,
"testRegex": "\\.e2e\\.js$",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
./e2e/environment.js
const {
DetoxCircusEnvironment,
SpecReporter,
WorkerAssignReporter,
} = require('detox/runners/jest-circus');
class CustomDetoxEnvironment extends DetoxCircusEnvironment {
constructor(config, context) {
super(config, context);
// Can be safely removed, if you are content with the default value (=300000ms)
this.initTimeout = 300000;
// This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
// This is strictly optional.
this.registerListeners({
SpecReporter,
WorkerAssignReporter,
});
}
}
module.exports = CustomDetoxEnvironment;
.detoxrc.json
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"skipLegacyWorkersInjection": true,
"apps": {
"ios": {
"type": "ios.app",
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/Example.app",
"build": "xcodebuild -workspace ios/Example.xcworkspace -configuration release -scheme Example -sdk iphonesimulator -derivedDataPath ios/build"
},
"android": {
"type": "android.apk",
"binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY"
}
},
"devices": {
"simulator": {
"type": "ios.simulator",
"device": {
"type": "iPhone 12 Pro"
}
},
"emulator": {
"type": "android.emulator",
"device": {
"avdName": "Pixel_3a_API_30_x86"
}
}
},
"configurations": {
"ios": {
"device": "simulator",
"app": "ios"
},
"android": {
"device": "emulator",
"app": "android"
}
}
}
It can't be this hard. Any help would be greatly appreciated.

Able to solve using Jest 27.0.1
I asked on github because I had the same problem as you and they gave me this solution

Related

How to setup plain text env vars in Expo build?

I'm working on an expo project and trying to link environment variables for build profiles. I was trying to achieve that using eas.json but I cannot get it to work.
I have two build profiles - development and production:
{
"cli": {
"version": ">= 3.3.1"
},
"build": {
"development": {
"distribution": "internal",
"env": {
"API_URL": "https://staging-api.example.com",
"STRIPE_ENV": "test"
},
"ios": {
"resourceClass": "m1-medium"
}
},
"production": {
"env": {
"API_URL": "https://api.example.com",
"STRIPE_ENV": "production"
},
"ios": {
"resourceClass": "m1-medium"
},
"autoIncrement": true
}
},
"submit": {
"production": {
...
}
}
}
Build command:
eas build --profile development --platform ios
Based on their documentation, I sohuld be able to use process.env.API_URL but it's undefined.
Am I missing something?
Putting those values in eas.json is only ensuring that those envs will be set during the build process on EAS. To pass them to the application code you need to pass those values to the extra field in app.config.js.
process.env.API_URL will be defined when evaluating app.config.js, but in your application code, you need to access those values via expo-constants package.

The "path" argument must be of type string. Received undefined. Failed to verify 1 contract(s)

I'm deploying smart contract to rinkeby network, then trying to verify the contract with
truffle run verify IzoneMember --network rinkeby
but it doesn't work and keep showing this message, however I've installed truffle-verify-plugin, react-script and cucumber.
PS C:\Users\dohva\Documents\Github Repo\NFT\truffle-starter-kit> truffle run verify IzoneMember --network rinkeby
Verifying IzoneMember
The "path" argument must be of type string. Received undefined
Failed to verify 1 contract(s): IzoneMember
here is my package.json
{
"name": "#chainlink/box",
"version": "0.6.0",
"description": "A Chainlink example in a Truffle box",
"scripts": {
"compile": "npx truffle compile",
"console:dev": "npx truffle console --network cldev",
"console:kovan": "npx truffle console --network kovan",
"depcheck": "echo '#chainlink/box' && depcheck --ignore-dirs=build/contracts || true",
"solhint": "solhint ./contracts/**/*.sol",
"lint": "yarn solhint",
"migrate:dev": "npx truffle migrate --reset --network cldev",
"migrate:kovan": "npx truffle migrate --network kovan",
"test": "npx truffle test"
},
"license": "MIT",
"dependencies": {
"#chainlink/contracts": "^0.1.9",
"#cucumber/cucumber": "^7.3.1",
"#openzeppelin/contracts": "^3.4.1",
"#truffle/hdwallet-provider": "^1.4.2",
"bip39": "^3.0.4",
"cucumber": "^7.0.0-rc.0",
"dotenv": "^8.6.0",
"react-scripts": "^4.0.3",
"web3": "^1.4.0"
},
"devDependencies": {
"#chainlink/belt": "^0.0.3",
"#chainlink/test-helpers": "0.0.5",
"#openzeppelin/test-helpers": "^0.5.10",
"chai": "^4.3.0",
"depcheck": "^1.3.1",
"solhint": "^3.3.2",
"truffle": "^5.3.1",
"truffle-plugin-verify": "^0.5.11"
},
"resolutions": {
"**/minimist": "^0.2.1",
"**/node-fetch": "^2.6.1",
"**/yargs-parser": "^13.1.2",
"**/mem": "^4.0.0"
},
"react-scripts": "^4.0.3"
}
and here is my truffle-config.js
const HDWalletProvider = require('#truffle/hdwallet-provider')
require('dotenv').config()
const mnemonic = process.env.MNEMONIC
const url = process.env.RINKEBY_RPC_URL
module.exports = {
networks: {
rinkeby: {
provider: () =>
new HDWalletProvider({
mnemonic: process.env.MNEMONIC,
providerOrUrl: "https://rinkeby.infura.io/v3/dd2fabf723e1433ba4a9339cae33afa6",
numberOfAddresses: 1,
shareNonce: true,
}),
network_id: '4',
},
development: {
host: 'localhost',
port: 7545,
network_id: '*', // Match any network id
},
mainnet: {
provider: () => {
return new HDWalletProvider(process.env.MAINNET_MNEMONIC, process.env.MAINNET_RPC_URL)
},
network_id: '1',
skipDryRun: true,
},
},
compilers: {
solc: {
version: "^0.6.6",
}
},
api_keys: {
etherscan: "52NGDWZMANK51AXZ6ST3Z9PQS97WZP8X15"
},
plugins: [
'truffle-plugin-verify'
]
}
For me, I had my imported contracts as e.g.,
../node_modules/#openzeppelin
I removed the ../node_modules/ and it was fixed

Can someone help me resolve this problem? Fatal error: Unable to find local grunt

I am learning hybris and I started using smartedit. The problem is that when I run ant clean all or ant updatesystem I get this error.
Running grunt default
grunt-cli: The grunt command line interface (v1.3.2)
Fatal error: Unable to find local grunt.
If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:
https://gruntjs.com/getting-started
What have I done till now:
I have grunt-cli installed globally, and grunt installed locally. Also, I run npm install.
Here is my packege.json file:
{
"name": "name",
"version": "1.0.0",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "^1.4.1",
"grunt-contrib-jshint": "^3.0.0",
"grunt-contrib-watch": "^1.1.0"
},
"dependencies": {},
"description": "desc"
}
Here is my Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
globals: {
jQuery: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['jshint']);
};
I tried a bunch of ways to resolve this problem but nothing seemed to work. Can someone help me out?

inject is not defined - CodeceptJs and CucumberJs

It's my first time using CodeceptJs and I'm struggling to run my feature file as the IDE asks me to implement steps for my scenario but this is already done, so I feel it may be searching for them somewhere other than the specified under the codecept.conf.js file?
When I run npx codeceptjs gherkin:steps or snippets on the terminal I get this message saying Could not include object Step Definition from ./step_definitions/steps.js from module '/Users/myUser/IdeaProjects/codeceptjs_webdriver/step_definitions/steps.js' The "from" argument must be of type string. Received undefined .
I then move the step_definitions folder to inside features as read that this would be the default location for these and now get an inject is not defined error, which may be the actual cause for the issue I'm getting, but not sure what to do to fix it.
I've tried on IntelliJ Ultimate, Webstorm and VSCode but get the same on all of them.
basic.feature
Feature: Business rules
In order to achieve my goals
As a persona
I want to be able to interact with a system
Scenario: do something
Given I have a defined step
steps.js
const {Given} = require('cucumber');
const {I} = inject();
Given(/^I have a defined step$/, function () {
I.amOnPage('/');
});
codecept.conf.js
exports.config = {
output: './output',
helpers: {
WebDriver: {
url: 'https:www.google.com',
browser: 'chrome'
}
},
include: {
I: './steps_file.js'
},
mocha: {},
bootstrap: null,
teardown: null,
hooks: [],
gherkin: {
features: './features/*.feature',
steps: ['./step_definitions/steps.js']
},
plugins: {
screenshotOnFail: {
enabled: true
},
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
}
},
tests: './*_test.js',
name: 'codeceptjs_webdriver'
}
package.json
{
"name": "codeceptjs_webdriver",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"codeceptjs": "^3.0.0",
"cucumber": "^5.0.1"
},
"dependencies": {
"#codeceptjs/configure": "^0.6.0"
},
"description": ""
}
IntelliJ Ultimate 2020.2
And here my Github repo
Thank you very much.
It's working now and I've come back to update it here if useful to someone else.
Was able to keep the steps under step_definitions/steps folder (not the one inside the features folder). To fix the non implemented issue had to install the wdio dependency. In order for this to take effect properly through running npm install both node_modules and package-lock.json had to be deleted to be freshly regenerated.
updated package.json
{
"name": "codeceptjs_webdriver",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "npx codeceptjs run"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {},
"dependencies": {
"#wdio/selenium-standalone-service": "^6.6.2",
"codeceptjs": "^2.6.8",
"codeceptjs-assert": "0.0.4",
"webdriverio": "6.3.6"
},
"description": ""
}
updated codecept.conf.js
exports.config = {
output: './output',
helpers: {
WebDriver: {
url: 'https://www.google.com',
browser: 'chrome'
}
},
include: {
I: './steps_file.js'
},
mocha: {},
bootstrap: null,
teardown: null,
hooks: [],
gherkin: {
features: './features/*.feature',
steps: ['./step_definitions/steps.js']
},
plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone']
// additional config for service can be passed here
},
screenshotOnFail: {
enabled: true
},
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
},
tests: './*_test.js',
name: 'codeceptjs_webdriver'
}

UnknownError: Connection refused (Connection refused)

I'm running a grunt test within a MEAN JS stack app and found an issue that I can't work out its cause.
Running webdriver-manager on its own, i.e. webdriver-manager start, works fine, but running via the grunt test task seems to fail.
I also noticed that the port is different (not 4444). Not sure how to change this either.
Running "protractor:e2e" (protractor) task
webdriver-manager path: /Users/valdy/Development/MeanJSApp/node_modules/protractor/bin/webdriver-manager
selenium standalone is up to date.
chromedriver is up to date.
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.0.115:64594/wd/hub
/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108
var template = new Error(this.message);
^
UnknownError: Connection refused (Connection refused)
at new bot.Error (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)
at Object.bot.response.checkResponse (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)
at /Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24
at promise.ControlFlow.runInFrame_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at wrappedCtr.notify (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at promise.Promise.notify_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at promise.Promise.notifyAll_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at Builder.build (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/builder.js:445:22)
at LocalDriverProvider.DriverProvider.getNewDriver (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
at Runner.createBrowser (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:182:37)
at /Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:759:13)
at /Users/valdy/Development/MeanJSApp/node_modules/q/q.js:573:44
[launcher] Process exited with error code 1
>>
Warning: Tests failed, protractor exited with code: 1 Use --force to continue.
Aborted due to warnings.
This is the config for tests.js (/config/assets/tests.js):
'use strict';
module.exports = {
tests: {
// client: ['modules/*/tests/client/**/*.js'],
client: ['modules/forum/tests/client/**/*.js'],
// server: ['modules/*/tests/server/**/*.js'],
server: ['modules/forum/tests/server/**/*.js'],
e2e: ['modules/*/tests/e2e/**/*.js']
// e2e: ['modules/forum/tests/e2e/**/*.js']
}
};
I also found that protractor's config.json, under /node_module/protractor/config.json has this configuration:
{
"webdriverVersions": {
"selenium": "2.47.1",
"chromedriver": "2.19",
"iedriver": "2.47.0"
}
}
And this is my own protractor.config.js, in the root of the web app:
'use strict';
// Protractor configuration
var config = {
specs: ['modules/*/tests/e2e/*.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;
And here is protractor's npm descriptor (/node_module/protractor/package.json):
{
"_args": [
[
{
"raw": "Protractor#2.5.1",
"scope": null,
"escapedName": "Protractor",
"name": "Protractor",
"rawSpec": "2.5.1",
"spec": "2.5.1",
"type": "version"
},
"/Users/valdy/Development/MeanJSApp"
]
],
"_from": "Protractor#2.5.1",
"_id": "protractor#2.5.1",
"_inCache": true,
"_location": "/protractor",
"_nodeVersion": "0.12.7",
"_npmUser": {
"name": "angularcore",
"email": "angular-core+npm#google.com"
},
"_npmVersion": "2.11.3",
"_phantomChildren": {
"boom": "2.10.1",
"chalk": "1.1.3",
"combined-stream": "1.0.5",
"core-util-is": "1.0.2",
"cryptiles": "2.0.5",
"ctype": "0.5.3",
"forever-agent": "0.6.1",
"graceful-readlink": "1.0.1",
"hoek": "2.16.3",
"inherits": "2.0.3",
"is-my-json-valid": "2.16.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"lru-cache": "2.7.3",
"oauth-sign": "0.8.2",
"sigmund": "1.0.1",
"sntp": "1.0.9",
"string_decoder": "0.10.31",
"stringstream": "0.0.5",
"tough-cookie": "2.3.2"
},
"_requested": {
"raw": "Protractor#2.5.1",
"scope": null,
"escapedName": "Protractor",
"name": "Protractor",
"rawSpec": "2.5.1",
"spec": "2.5.1",
"type": "version"
},
"_requiredBy": [
"#USER",
"/grunt-protractor-runner",
"/gulp-protractor"
],
"_resolved": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz",
"_shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd",
"_shrinkwrap": null,
"_spec": "Protractor#2.5.1",
"_where": "/Users/valdy/Development/MeanJSApp",
"author": {
"name": "Julie Ralph",
"email": "ju.ralph#gmail.com"
},
"bin": {
"protractor": "bin/protractor",
"webdriver-manager": "bin/webdriver-manager"
},
"bugs": {
"url": "https://github.com/angular/protractor/issues"
},
"dependencies": {
"accessibility-developer-tools": "~2.6.0",
"adm-zip": "0.4.4",
"glob": "~3.2",
"html-entities": "~1.1.1",
"jasmine": "2.3.2",
"jasminewd": "1.1.0",
"jasminewd2": "0.0.6",
"lodash": "~2.4.1",
"minijasminenode": "1.1.1",
"optimist": "~0.6.0",
"q": "1.0.0",
"request": "~2.57.0",
"saucelabs": "~1.0.1",
"selenium-webdriver": "2.47.0",
"source-map-support": "~0.2.6"
},
"description": "Webdriver E2E test wrapper for Angular.",
"devDependencies": {
"chai": "~3.3.0",
"chai-as-promised": "~5.1.0",
"cucumber": "~0.6.0",
"expect.js": "~0.2.0",
"express": "~3.3.4",
"jshint": "2.5.0",
"mocha": "2.3.3",
"rimraf": "~2.2.6"
},
"directories": {},
"dist": {
"shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd",
"tarball": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz"
},
"gitHead": "645133d557f1059d9e885f2566fc4c29ce7c19cc",
"homepage": "https://github.com/angular/protractor",
"keywords": [
"angular",
"test",
"testing",
"webdriver",
"webdriverjs",
"selenium"
],
"license": "MIT",
"main": "lib/protractor.js",
"maintainers": [
{
"name": "juliemr",
"email": "ju.ralph#gmail.com"
},
{
"name": "angularcore",
"email": "angular-core+npm#google.com"
}
],
"name": "protractor",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/angular/protractor.git"
},
"scripts": {
"pretest": "jshint lib spec scripts",
"start": "node testapp/scripts/web-server.js",
"test": "node scripts/test.js"
},
"version": "2.5.1"
}
Here is my best guess at what's going on:
You are launching with the selenium standalone server locally using your ip address and a port that is not 4444. This means that you did not select seleniumAddress: "http://localhost:4444/wd/hub" or directConnect: true. I'll have a code snippet below of what this looks like.
If you are launching locally and not on Travis, then Protractor launches by the Chrome browser by default. This also means that you should have downloaded the ChromeDriver.
You should upgrade from Protractor 2.5 to the latest. Protractor is strongly coupled with the entire stack: selenium-webdriver, the standalone server, browser drivers and browsers. If you are using an up-to-date browser and Protractor 2.5, then probably webdriver-manager downloaded old binaries that may be incompatible with your browser.
Here is the code snippet:
exports.config = {
// option 1. launches a selenium standalone server. this is helpful if
// you launch it with "webdriver-manager start"
// seleniumAddress: "http://localhost:4444/wd/hub",
//
// option 2. launch browser directly using browser binaries
// directConnect: true,
//
// option 3. do not include either seleniumAddress or directConnect
// and this option will launch the selenium standalone server using
// your ip address.
//
// option 4: launch with saucelabs or browserstack options
}
This file relates to this one where you define your config, set capabilities only for travis and export the config.
'use strict';
// Protractor configuration
var config = {
specs: ['modules/*/tests/e2e/*.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;