简体   繁体   English

节点命令不执行星号路径

[英]Node command doesn't execute asterisk path

I have a folder Test/Automation contains many test cases, egajs, b.js, c.js, etc. 我有一个文件夹Test / Automation,其中包含许多测试用例,egajs,b.js,c.js等。

I am using WebdriverJs Selenium. 我正在使用WebdriverJs Selenium。 I use this command to execute all the tests in this folder: 我使用此命令来执行此文件夹中的所有测试:

node Test/**/*.js

But only a.js was executed and then it's done. 但是只有a.js被执行,然后就完成了。 Anyone knows the reason why? 有人知道原因吗? Is there something wrong with this? 这有什么问题吗? Thanks 谢谢

You have to declare that js in server.js. 您必须在server.js中声明该js。 For example: 例如:

var express = require('express'),
bodyParser = require('body-parser'),
modulea = require('./modules/a'),
moduleb = require('./modules/b')

If you have multiple *.js (javascript) files in same directory as well. 如果您在同一目录中也有多个* .js(javascript)文件。 node wont run multiple files in same command line. 节点不会在同一命令行中运行多个文件。 eg if you had a.js,b.js,c.js within test and then, 例如,如果您在测试中包含a.js,b.js,c.js,

node test/*.js

will return output of a.js only. 将仅返回a.js的输出。

Another proposal, Assuming you doing some form of automation with different scenarios, 另一个建议,假设您在不同的情况下进行某种形式的自动化,

try creating a batch executable (or bash script in case of linux) with something like this, 尝试使用以下方式创建批处理可执行文件(如果是Linux,则创建bash脚本),

node test/l1/a.js
node test/l1/a1.js
node test/l2/b.js

this will give you additional option to control test/js to execute. 这将为您提供控制test / js执行的其他选项。

Thanks guys, I have found a solution, I wrapped Js in mocha format, then I can them all with this command : 谢谢大家,我找到了一个解决方案,我将Js封装为mocha格式,然后可以使用以下命令将它们全部打包:

mocha Test/Automation/*.js

It works as I want. 它按我的意愿工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM