10

I'm trying to write a test automation script using appium, jasmine, and perfecto mobile. I'm using the project cloned from the following URL with my own configuration Appium Javascript Example

The problem is when I execute the npm test command I get the following error

node_modules is not recognized as an internal or external command

This is how the packages.json script looks like:

  {
  "name": "perfecto_appium_sample",
  "version": "1.0.0",
  "description": "The following sample shows how to Install an application and use WebDriverIO to automate and test it.<br/> It uses selendroid test application which can be downloaded from [here](https://github.com/PerfectoCode/AppsForSamples/tree/master/selendroid-test-app-0.17.0).",
  "main": "perfectoSpec.js",
  "scripts": {
    "test": "node_modules/webdriverio/bin/wdio wdio.conf.js",
    "start": "wdio wdio.conf.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "wdio": "^0.3.3",
    "wdio-jasmine-framework": "^0.2.19",
    "wdio-mocha-framework": "^0.5.12"
  },
  "dependencies": {
    "wd": "^1.5.0",
    "webdriverio": "^4.10.2"
  },
  "keywords": []
}
kgangadhar
  • 4,886
  • 5
  • 36
  • 54
Noel Omondi
  • 551
  • 1
  • 6
  • 23

3 Answers3

22

You need to provide a relative path properly:

"scripts": {
    "test": "node ./node_modules/webdriverio/bin/wdio wdio.conf.js",
    "start": "wdio wdio.conf.js"
  }
kgangadhar
  • 4,886
  • 5
  • 36
  • 54
  • 5
    This is on Windows, when I add the dot, the error becomes '.' is not recognized as an internal or external command – Noel Omondi Feb 16 '18 at 09:44
  • 2
    How about "`node ./node_modules/webdriverio/bin/wdio wdio.conf.js`" – kgangadhar Feb 16 '18 at 09:46
  • I have tried this: "scripts": { "test": node "./node_modules/webdriverio/bin/wdio wdio.conf.js", "start": "wdio wdio.conf.js" }, It does not work as its not a correct JSON string format – Noel Omondi Feb 16 '18 at 09:50
1

Just remove the paths "node_modules/webdriverio/bin/" and simply specify "wdio wdio.conf.js". It should work.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 02 '22 at 09:25
0

It seems like you are trying to execute a command from the node_modules/.bin directory, but your terminal is unable to find it. Use npx test not npm test

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – pierpy Apr 22 '23 at 19:54