getting test failed on typing command npm test - react-native

I am getting an error which in turns return test failed. Not able to find out the solution to it. Have checked but did not found an appropriate answer for it
I have tried following things:
1. Check babel version :using 7.5.5
2. https://github.com/GeekyAnts/NativeBase/issues/977
3. https://gist.github.com/iamvery/4d4b0ef68cd1f2de81b858fe3a2d08c5
4. https://github.com/GeekyAnts/NativeBase/issues/2579
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import connectStyle, { clearThemeCache } from "./src/connectStyle";
SyntaxError: Unexpected identifier
at ScriptTransformer._transformAndBuildScript (../../node_modules/#jest/transform/build/ScriptTransformer.js:471:17)
at ScriptTransformer.transform (../../node_modules/#jest/transform/build/ScriptTransformer.js:513:25)
at Object.<anonymous> (../../node_modules/native-base/src/index.js:1:1)
Test Suites: 1 failed, 1 passed, 2 total
Tests: 4 passed, 4 total
Snapshots: 1 passed, 1 total
Time: 2.022s
Ran all test suites.
npm ERR! Test failed. See above for more details.
Actual result is test failed as have shown above
Expected result is test should pass

you can add this to your jest config file
"transformIgnorePatterns": [ "node_modules/(?!react-native|#shoutem|react-clone-referenced-element|native-base-shoutem-theme)" ]

Related

Selenium-side-runner failing with `New window did not appear before timeout`

I am trying to run a selenium IDE script (.side) from the command line using side-runner. Currently, the test runs successfully from the IDE, and appears to work successfully from the command line but then fails, throwing: New window did not appear before timeout.
This is my Selenium IDE test. The test is included in the default suite so it should be run. However, when I run it from the command line with:
$ selenium-side-runner -c "browserName=firefox" firefox-test.side
I get:
info: Running firefox-test.side
FAIL ./DefaultSuite.test.js (12.71s)
Default Suite
✕ wikipedia (9332ms)
● Default Suite › wikipedia
New window did not appear before timeout
5 | return hndls.find(h => (!handles.includes(h)));
6 | }
> 7 | throw new Error("New window did not appear before timeout");
| ^
8 | }
9 |
10 | module.exports = {
at Object.waitForWindow (utils.js:7:9)
at Object.<anonymous>.tests.wikipedia (commons.js:34:18)
at Object.<anonymous> (DefaultSuite.test.js:11:5)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 13.353s
Ran all test suites.
However, I can see the firefox window and the tests appear to be working. The window closes, then a new firefox window appears and the error is thrown. I have tried increasing the timeout:
$ selenium-side-runner --timeout 600000 -c "browserName=firefox" firefox-test.side
with the same error. Any ideas?

ReferenceError: [BABEL] /home/sriram/Desktop/gooodbet/client/scripts/test.js: Unknown option: /node_modules/babel-preset-react-app/index.js.overrides

I am getting the below error while running npm test using jest . I have express app inside which there is client folder which is a create-react-app-2 and when I ejected it the problem is showing up . what to do now ??
Test suite failed to run
ReferenceError: [BABEL] /home/sriram/Desktop/gooodbet/client/scripts/test.js: Unknown option: /home/sriram/Desktop/gooodbet/client/node_modules/babel-preset-react-app/index.js.overrides. Check out http://babeljs.io/docs/usage/options/ for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`
For more detailed information on preset configuration, please see https://babeljs.io/docs/en/plugins#pluginpresets-options. (While processing preset: "/home/sriram/Desktop/gooodbet/client/node_modules/babel-preset-react-app/index.js")
at Logger.error (node_modules/babel-core/lib/transformation/file/logger.js:41:11)
at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20)
at node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
at node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
at Array.map (<anonymous>)
at OptionManager.resolvePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (node_modules/babel-core/lib/transformation/file/index.js:212:65)
RUNS tests/integration/localAuth.test.js
FAIL tests/integration/localAuth.test.js
localAuth
POST /api/signup
✓ should signup successfully (536ms)
✕ should send 400 for not having email (8ms)
● localAuth › POST /api/signup › should send 400 for not having email
Bad Request
at Test.Object.<anonymous>.Request.callback (node_modules/superagent/lib/node/index.js:804:15)
at IncomingMessage.parser (node_modules/superagent/lib/node/index.js:1036:18)
Test Suites: 2 failed, 2 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 total
Time: 2.378s
Ran all test suites.
I followed this link to
and undo eject of create-react-app and everything works now

Jest test failing unexpected export react native

I have freshly generated React-Native project and yarn test is failing.
jest-expo preset is present in package.json file.
FAIL ./App.test.js
● Test suite failed to run
/Users/haito/Projects/react-native/TalkToMe/node_modules/react-router-native/main.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from 'react-router'
^^^^^^
SyntaxError: Unexpected token export
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:305:17)
at Object.<anonymous> (App.js:2:24)
at Object.<anonymous> (App.test.js:2:10)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.071s
Ran all test suites.
Edit added babel preset:
FAIL ./App.test.js
● Test suite failed to run
[BABEL] /Users/haito/Projects/react-native/TalkToMe/node_modules/react-native/jest/setup.js: Plugin/Preset files are not allowed to export objects, only functions.
at createDescriptor (node_modules/#babel/core/lib/config/option-manager.js:303:11)
at node_modules/#babel/core/lib/config/option-manager.js:154:12
at Array.map (<anonymous>)
at node_modules/#babel/core/lib/config/option-manager.js:153:48
at cachedFunction (node_modules/#babel/core/lib/config/caching.js:48:17)
at OptionManager.mergeOptions (node_modules/#babel/core/lib/config/option-manager.js:47:18)
at OptionManager.init (node_modules/#babel/core/lib/config/option-manager.js:115:14)
at manageOptions (node_modules/#babel/core/lib/config/option-manager.js:31:30)
at loadConfig (node_modules/#babel/core/lib/config/index.js:15:37)
at transformSync (node_modules/#babel/core/lib/transform-sync.js:13:36)

gulp-npm-test running Jest tests (all passing), but claiming to fail

I've installed gulp-npm-test following their documentation, that is, in my gulp directory I've got a file test.js that looks like this:
var gulp = require('gulp')
require('gulp-npm-test')(gulp)
var gulp = require('gulp-npm-test')(gulp, {
withoutNpmRun: false
})
But when I run gulp test I get the output like the following:
[17:12:41] Using gulpfile ~/my-project/gulpfile.js
[17:12:41] Starting 'test'...
> my-project#0.0.1 test /Users/wogsland/my-project
> jest
PASS frontend/tests/components/atoms/InputText.test.js
.
.
(many more Jest test passes, no fails)
.
.
FAIL gulp/tasks/test.js
● Test suite failed to run
Your test suite must contain at least one test.
at onResult (node_modules/jest/node_modules/jest-cli/build/TestRunner.js:192:18)
Test Suites: 1 failed, 135 passed, 136 total
Tests: 135 passed, 135 total
Snapshots: 209 passed, 209 total
Time: 92.237s
Ran all test suites.
npm ERR! Test failed. See above for more details.
What am I missing here? I've go a bunch of tests
Looks like the matcher that figures out which files are tests, matches everything that includes in the filename test.js. The default is [ '**/__tests__/**/*.js?(x)', '**/?(*.)(spec|test).js?(x)' ]. So either adapt this one, its testMatch in your jest settings. Or use testPathIgnorePatterns to exclude the /gulp folder.

Getting ReferenceError: fetch is not defined when running react native tests in mocha

When running react-native tests in mocha, I'm getting the following error:
> mocha --require test/init.js --compilers js:test/compiler.js 'src/**/*.spec.js'
Initializing tap mocha reporter...
1..7
ok 1 test1
…
not ok 7 test7
ReferenceError: fetch is not defined
at foo (src/foo.js:59:8)
at Context.<anonymous> (src/__specs__/foo.spec.js:9:30)
# tests 7
# pass 6
# fail 1
npm ERR! Test failed. See above for more details.
The problem was that fetch isn't available in a node environment like mocha. I'm not sure why react-native-mock (which I'm also using) doesn't have a mock for it, but the solution was to require isomorphic-fetch when initializing my mocha tests.
Specifically, add an init file to your mocha command-line if you don't have one already:
> mocha --require init.js …
and in init.js, require isomorphic-fetch:
require('isomorphic-fetch')
Then re-run mocha:
> mocha --require test/init.js --compilers js:test/compiler.js 'src/**/*.spec.js' && standard
Initializing tap mocha reporter...
1..7
ok 1 test1
…
ok 7 test7
# tests 7
# pass 7
# fail 0