Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: TypeError: Cannot read property 'toString' of null #11

Open
mpochron opened this issue Aug 9, 2015 · 11 comments
Open

bug: TypeError: Cannot read property 'toString' of null #11

mpochron opened this issue Aug 9, 2015 · 11 comments
Assignees

Comments

@mpochron
Copy link

mpochron commented Aug 9, 2015

I'm new user, and starting to use this plugin cordova.

C:\Developer\Projects\p>cordova-test android test/mocha
? Parsing cli params
{"platform":"android","platform_path":"C:\\Developer\\Projects\\p\\platforms\\android","tests_path":"C:\\Developer\\Projects\\p\\test/mocha","compile":true,"env":"mocha","env_files":"*.js","isLocal":true}

? Checking selected platform is supported
ANDROID

? Error: Tests path not found, C:\Developer\Projects\p\test/mocha

C:\Developer\Projects\p>cordova-test android test/mocha
? Parsing cli params
{"platform":"android","platform_path":"C:\\Developer\\Projects\\p\\platforms\\android","tests_path":"C:\\Developer\\Projects\\test/mocha","compile":true,"env":"mocha","env_files":"*.js","isLocal":true}

? Checking selected platform is supported
ANDROID

? Error: Tests path not found, C:\Developer\Projects\p\test/mocha

C:\Developer\Projects\p>cordova-test android tests/mocha
? Parsing cli params
{"platform":"android","platform_path":"C:\\Developer\\Projects\\p\\platforms\\android","tests_path":"C:\\Developer\\Projects\\p\\tests/mocha","compile":true,"env":"mocha","env_files":"*.js","isLocal":true}

? Checking selected platform is supported
ANDROID

? Checking test(s) path exists
C:\Users\Machei\AppData\Roaming\npm\node_modules\cordova-test\node\CDVTest.js:98
      return child.stdout.toString();
                         ^
TypeError: Cannot read property 'toString' of null
    at CDVTestLocal.get_cordova_version (C:\Users\Machei\AppData\Roaming\npm\node_modules\cordova-test\node\CDVTest.js:98:26)
    at CDVTestLocal.checkSettings (C:\Users\Machei\AppData\Roaming\npm\node_modules\cordova-test\node\CDVTest.js:164:30)
    at CDVAutomator.run (C:\Users\Machei\AppData\Roaming\npm\node_modules\cordova-test\node\CDVAutomator.js:57:35)
    at Object.<anonymous> (C:\Users\Machei\AppData\Roaming\npm\node_modules\cordova-test\bin\cli:18:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
@mpochron
Copy link
Author

mpochron commented Aug 9, 2015

That problem from file cordova-test/node/CDVTest.js :

value: function get_cordova_version() {
      var child = _child_process2['default'].spawnSync("cordova", ["-v"]);
      if (child.stderr && child.stderr.toString() != "") {
        return false;
      }
      console.log(child.stdout); // here null
      return child.stdout.toString();
    }

child.stdout pirnts null , also i have [email protected]

Got error : error: { [Error: spawnSync ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawnSync'

@vrunoa
Copy link
Member

vrunoa commented Aug 9, 2015

Hey @machei, good to hear you're trying cordova-test. I actually didn't test it on Windows, I'll try to make it work with you.

First, I see you got this error

? Error: Tests path not found, C:\Developer\Projects\p\test/mocha

Are you executing cordova-test inside a cordova project ?

I'll take a look now, in the script that gets cordova version, to check why it fails.

Do you have cordova in the global path or you execute it from it folder; if you exec
cordova -v in a terminal, does it give you the version ?
Or you use it like;
C:\\my\folder\to\cordova -v ?

@mpochron
Copy link
Author

mpochron commented Aug 9, 2015

? Error: Tests path not found, C:\Developer\Projects\p\test/mocha - I know about athat error, I had wrong with folder name.

Still error caught with cordova -v and appium -v. I have placed string to returns of these functions like that return "5.0.0".

Cordova and appium are installed globally, these command works anywhere.

Other error still:

Machei@MacheiPC  /cygdrive/c/Developer/Projects/p   develop ± cordova-test android tests/mocha
✓ Parsing cli params
{"platform":"android","platform_path":"C:\\Developer\\Projects\\p\\platforms\\android","tests_path":"C:\\Developer\\Projects\\p\\tests/mocha","compile":true,"env":"mocha","env_files":"*.js","isLocal":true}

✓ Checking selected platform is supported
ANDROID

✓ Checking test(s) path exists
✓ Cordova installed, cordova version: 5.0.0
✓ Getting cordova project info
Project name: Test Proejct
Package name: app.test.project

Compiling cordova application, this may take a while!
✓ Cordova project compiled
✓ Checking compiled application exists
✓ Checking appium is installed
Appium installed, appium version: 1.4.10
✓ Checking appium is running & available
✓ Platform capabilities updated
Running test; mocha C:\Developer\Projects\p\tests/mocha\01_splash.js --platform android
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn mocha ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
    at child_process.js:1144:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3
 ✘  Machei@MacheiPC  /cygdrive/c/Developer/Projects/p  develop ± appium -v
1.4.10
 ✘  Machei@MacheiPC  /cygdrive/c/Developer/Projects/p  develop ±

@vrunoa
Copy link
Member

vrunoa commented Aug 9, 2015

mmm, it shouldnt throw an error on cordova -v since cordova build android does work.

can you try with cordova-test android tests\mocha ? maybe windows is getting a wrong path with a / as separator

@mpochron
Copy link
Author

mpochron commented Aug 9, 2015

cordova-test android tests\mocha \\ Error: Tests path not found, ...\p\testsmocha
cordova-test android tests\\mocha \\ error in prev comment
cordova-test android tests/mocha \\ error in prev comment

I tried to type command following as abowe.

My mocha is fine working in other way:

✘  Machei@MacheiPC  /cygdrive/c/Developer/Projects/p/tests/mocha   feature/teste2e ± mocha 01_splash.js

  Array
    #indexOf()
      √ should return -1 when the value is not present


  1 passing (6ms)
``

@vrunoa
Copy link
Member

vrunoa commented Aug 9, 2015

I'll create a windows vm and check what's the problem. I'll give you feedback soon.

@vrunoa vrunoa self-assigned this Aug 9, 2015
@vrunoa
Copy link
Member

vrunoa commented Aug 11, 2015

Hey @machei, I just made an improvement on the path parser. Can you reinstall the cli, npm install -g cordova-test and try again ?
I'm still investigating why the cli trhows an error when getting cordova(and appium) version.

@DavidBriglio
Copy link

Has there been any update on this issue? I am experiencing the same thing:

return child.stdout.toString();
                         ^

TypeError: Cannot read property 'toString' of null

This is from within CDVTest.js:103

@malutanpetronel
Copy link

I have the same issue (I think...)

TypeError: Cannot read property 'toString' of null
at CDVTestLocal.getCordovaVersion (C:\Users\Petro\AppData\Roaming\npm\node_modules\cordova-test\dist\CDVTest.js:103:26)
at CDVTestLocal.checkSettings (C:\Users\Petro\AppData\Roaming\npm\node_modules\cordova-test\dist\CDVTest.js:166:29)
at CDVAutomator.run (C:\Users\Petro\AppData\Roaming\npm\node_modules\cordova-test\dist\CDVAutomator.js:63:35)
at Object. (C:\Users\Petro\AppData\Roaming\npm\node_modules\cordova-test\bin\cli:21:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)

@liaolunhui
Copy link

same of cordova 9.0.0 ([email protected])

@vrunoa
Copy link
Member

vrunoa commented Oct 29, 2019

Sorry for the super late reply, this project was unsupported due to lack of time. I just added the label as deprecated. I just tried the project on MacOs and it works. I'm creating a new release, but won't be able to help much, especially on Windows.

This is working with 9.0.0 ([email protected]) on MacOs
#23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants