我真的在这个问题上摸不着头脑,并且花了大约1.5天试图解决问题
我认为问题与以某种方式重置的权限有关 - 我怀疑它发生在我为Windows双启动分区启动阵营助手之后
环境:
使用Alsatian和Zalenium框架在ts-node上编写硒测试用例,使用Alsatian和Zalenium框架 - 以下命令用于初始化测试运行器
yarn run ts-node Tests/runner.ts --tap
纱线环境正在通过brew
运行的package.json:
{
"dependencies": {
"@types/dotenv": "^4.0.2",
"@types/selenium-webdriver": "^3.0.8",
"alsatian": "^2.2.1",
"axios": "^0.17.1",
"dotenv": "^5.0.0",
"moment": "^2.20.1",
"selenium-webdriver": "^4.0.0-alpha.1",
"tap-spec": "^4.1.1",
"ts-node": "^4.1.0",
"tslib": "1.8.1",
"typescript": "^2.6.2"
}
}
runner.ts:
import tapSpec = require('tap-spec');
import { TestSet, TestRunner } from "alsatian";
import { config as dotenv } from 'dotenv';
(async () =>
{
// Load up any pseudo environment variables
dotenv({ path: __dirname + '/../.env' });
// Setup the alsatian test runner
let testRunner = new TestRunner();
let tapStream = testRunner.outputStream;
let testSet = TestSet.create();
testSet.addTestsFromFiles('/**/*/*.spec.ts');
// This will output a human readable report to the console.
tapStream.pipe(tapSpec()).pipe(process.stdout);
// Runs the tests
await testRunner.run(testSet);
})()
.catch(e =>
{
console.error(e);
process.exit(1);
});
问题:
我怀疑使用bootcamp assistant
安装双启动窗口后问题就出现了我在另一个项目中在windows上工作了3-4天,当我回来时,开始获得权限问题
最初他们沿着{ Error: EACCES: permission denied, scandir '/Library/Application Support/xxxx'
我使用如下所述的chmod解决了 - 现在我被卡住 - 读取第7点和第8点,我不知道导致问题的原因 - 但我怀疑它的纱线权限
我曾经 - 也更新到了之前的typescript 2.7.1,因为我在tsconfig中使用选项" strictPropertyInitialization":false - 最初我认为这会导致一些问题,但是恢复到2.6 .2还没有解决它
授予每个投诉文件夹sudo chmod -R 777' / Library / Application Support',现在抱怨无法访问' / System / Library / User Template' ,不能在这里使用chmod,因为我收到错误,操作不允许
纱线运行ts-node Tests / runner.ts --tap给出:
警告package.json:没有许可证字段 $ /Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/.bin/ts-node Tests / runner.ts --tap {错误:EACCES:权限被拒绝,scandir' /系统/库/用户模板' at Object.fs.readdirSync(fs.js:924:18) 在GlobSync._readdir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:288:41) 在GlobSync._readdirInGlobStar(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:267:20) 在GlobSync._readdir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:276:17) 在GlobSync._processReaddir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:137:22) 在GlobSync._process(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:132:10)0 在GlobSync._processReaddir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:207:10) 在GlobSync._process(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:132:10) 在GlobSync._processGlobStar(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:380:10) 在GlobSync._process(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:130:10) 错误:-13, 代码:' EACCES', 系统调用:' scandir', 路径:' /系统/库/用户模板' } 错误命令失败,退出代码为1。 info有关此命令的文档,请访问https://yarnpkg.com/en/docs/cli/run。
sudo yarn run ts-node Tests / runner.ts --tap给出:
{错误:EBADF:错误的文件描述符,scandir' / dev / fd / 13' at Object.fs.readdirSync(fs.js:924:18) 在GlobSync._readdir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:288:41) 在GlobSync._readdirInGlobStar(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:267:20) 在GlobSync._readdir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:276:17) 在GlobSync._processReaddir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:137:22) 在GlobSync._process(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:132:10) 在GlobSync._processReaddir(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:207:10) 在GlobSync._process(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:132:10) 在GlobSync._processGlobStar(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:380:10) 在GlobSync._process(/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:130:10) 错误:-9, 代码:' EBADF', 系统调用:' scandir', 路径:' / dev / fd / 13' } 错误命令失败,退出代码为1。
更新2017年2月1日至19日:
我已经放置了一个test.ts文件 - 除了打印到控制台之外什么都不做,如果我从yarn ts-node调用它,那就可以正常工作
yarn run ts-node Tests/test.ts
输出:
yarn run v1.3.2
warning package.json: No license field
$ /Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/.bin/ts-node Tests/test.ts
this is a test
✨ Done in 0.61s.
test.ts:
(async () =>
{
console.log("this is a test");
})()
.catch(e =>
{
console.error(e);
process.exit(1);
});
我也尝试过,@ ILI建议的注释 - 我在mac分区上使用磁盘工具中的First Aid修复了权限,因为brew不再支持sudo,我从brew中卸载了yarn,以及使用
将其添加到全局包中sudo yarn install yarn -g
但仍有相同的EACCESS错误 - 错误:EACCES:权限被拒,scandir' / Library / Application Support / OpenVPN / profile'
还尝试了运行纱线--verbose,没有从那里得到很多细节
yarn run --verbose ts-node Tests/runner.ts --tap
yarn run v1.3.2
warning package.json: No license field
verbose 0.331 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/.npmrc".
verbose 0.331 Checking for configuration file "/Users/dshamim/.npmrc".
verbose 0.331 Checking for configuration file "/usr/local/etc/npmrc".
verbose 0.332 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/.npmrc".
verbose 0.332 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/anex/.npmrc".
verbose 0.332 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/.npmrc".
verbose 0.332 Checking for configuration file "/Users/dshamim/Projects/Acurus/.npmrc".
verbose 0.332 Checking for configuration file "/Users/dshamim/Projects/.npmrc".
verbose 0.332 Checking for configuration file "/Users/dshamim/.npmrc".
verbose 0.333 Checking for configuration file "/Users/.npmrc".
verbose 0.333 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/.yarnrc".
verbose 0.333 Checking for configuration file "/Users/dshamim/.yarnrc".
verbose 0.334 Found configuration file "/Users/dshamim/.yarnrc".
verbose 0.334 Checking for configuration file "/usr/local/etc/yarnrc".
verbose 0.334 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/.yarnrc".
verbose 0.334 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/anex/.yarnrc".
verbose 0.334 Checking for configuration file "/Users/dshamim/Projects/Acurus/ANEX/.yarnrc".
verbose 0.335 Checking for configuration file "/Users/dshamim/Projects/Acurus/.yarnrc".
verbose 0.337 Checking for configuration file "/Users/dshamim/Projects/.yarnrc".
verbose 0.338 Checking for configuration file "/Users/dshamim/.yarnrc".
verbose 0.338 Found configuration file "/Users/dshamim/.yarnrc".
verbose 0.338 Checking for configuration file "/Users/.yarnrc".
verbose 0.34 current time: 2018-02-19T00:39:49.960Z
$ /Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/.bin/ts-node Tests/runner.ts --tap
{ Error: EACCES: permission denied, scandir '/Library/Application Support/OpenVPN/profile'
at Object.fs.readdirSync (fs.js:924:18)
at GlobSync._readdir (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:288:41)
at GlobSync._readdirInGlobStar (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:267:20)
at GlobSync._readdir (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:276:17)
at GlobSync._processReaddir (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:137:22)
at GlobSync._process (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:132:10)
at GlobSync._processReaddir (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:207:10)
at GlobSync._process (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:132:10)
at GlobSync._processGlobStar (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:380:10)
at GlobSync._process (/Users/dshamim/Projects/Acurus/ANEX/anex/ANEX.Website.ManagementPortal.Tests/node_modules/glob/sync.js:130:10)
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/Library/Application Support/OpenVPN/profile' }
verbose 51.049 Error: Command failed with exit code 1.
at /usr/local/Cellar/yarn/1.3.2/libexec/lib/cli.js:35620:15
at Generator.throw (<anonymous>)
at step (/usr/local/Cellar/yarn/1.3.2/libexec/lib/cli.js:92:30)
at /usr/local/Cellar/yarn/1.3.2/libexec/lib/cli.js:105:13
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
答案 0 :(得分:2)
有时候我们想念的是简单的事情,不要担心我们都在这里。
这是一个过度思考这个问题的案例,要从澳大利亚啤酒广告中窃取一条线,你需要“理解它”。 https://youtu.be/1MdAhVetBq8
你的简单测试脚本工作但主要测试运行器没有这样做的事实,会指出我踩着测试跑步者脚本的方向,而不是看着纱线或任何其他罪魁祸首。
事实证明,你在告诉alsatian在整个硬盘上搜索测试用例,其中一些文件夹没有访问权限。
变化:
testSet.addTestsFromFiles('/**/*/*.spec.ts');
要:
testSet.addTestsFromFiles('**/*/*.spec.ts');
或者:
testSet.addTestsFromFiles('./**/*/*.spec.ts');
所有这些都应该像你期望的那样工作。