Urucas / cordova-test

cli-tool to automate Appium tests suite for Cordova apps
MIT License
6 stars 8 forks source link

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

Open mpochron opened 9 years ago

mpochron commented 9 years ago

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 commented 9 years ago

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 cordova@5.0.0

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

vrunoa commented 9 years ago

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 commented 9 years ago

? 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 commented 9 years ago

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 commented 9 years ago
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 commented 9 years ago

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

vrunoa commented 9 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 5 years ago

same of cordova 9.0.0 (cordova-lib@9.0.1)

vrunoa commented 5 years ago

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 (cordova-lib@9.0.1) on MacOs https://github.com/Urucas/cordova-test/pull/23