Typescript+Gulp+Protractor => 找不到模块 config.js
Typescript+Gulp+Protractor => Cannot find module config.js
我正在尝试 运行 使用 gulp 的量角器。我能够 运行 前两个任务,但是当我尝试 运行 第三个任务时,它无法找到存储在以下路径中的 config.js 文件(Windows系统)
F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\config\config.js
gulpfile.js
import * as gulp from 'gulp';
import * as protractor from 'gulp-protractor';
gulp.task('webdriver-update', protractor.webdriver_update);
gulp.task('webdriver-standalone', protractor.webdriver_standalone);
gulp.task('run-prot', function () {
console.log('About to run the specs...........')
gulp.src(['ConvertedJSFiles/specs/*.js']).pipe(protractor.protractor({
configFile: 'ConvertedJSFiles/config/config.js'
})).on('error',function(e){
throw e;
});
});
console.log(protractor.getProtractorDir() + ' is the protractor directory ***');
控制台错误
F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build>gulp run-prot
F:\Selenium2\Protractor\TypeScriptProject\node_modules\.bin is the protractor directory ***
[18:16:17] Using gulpfile F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\gulpfile.js
[18:16:18] Starting 'run-prot'...
About to run the specs...........
[18:16:18] Finished 'run-prot' after 106 ms
[18:16:20] E/configParser - Error code: 105
[18:16:20] E/configParser - Error message: failed loading configuration file ConvertedJSFiles/config/config.js
[18:16:20] E/configParser - Error: Cannot find module 'F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\Convert
edJSFiles\config\config.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ConfigParser.addFileConfig (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\configParser.js:125:
26)
at Object.initFn [as init] (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\launcher.js:93:22)
at Object.<anonymous> (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\cli.js:112:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\gulpfile.js:11
throw e;
^
Error: protractor exited with code 105
问题是错误的目录引用。我用 "path" 包调试了它。下面是更新后的文件。
import * as gulp from 'gulp';
import * as protractor from 'gulp-protractor';
import * as path from 'path';
gulp.task('webdriver-update', protractor.webdriver_update);
gulp.task('webdriver-standalone', protractor.webdriver_standalone);
gulp.task('run-prot', function () {
console.log('About to run the specs...........')
let srcfiles=path.resolve('../specs/*.js');
console.log(srcfiles);
gulp.src([srcfiles]).pipe(protractor.protractor({
configFile: '../config/config.js'
})).on('error',function(e){
throw e;
});
});
console.log(protractor.getProtractorDir() + ' is the protractor directory ***');
我正在尝试 运行 使用 gulp 的量角器。我能够 运行 前两个任务,但是当我尝试 运行 第三个任务时,它无法找到存储在以下路径中的 config.js 文件(Windows系统)
F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\config\config.js
gulpfile.js
import * as gulp from 'gulp';
import * as protractor from 'gulp-protractor';
gulp.task('webdriver-update', protractor.webdriver_update);
gulp.task('webdriver-standalone', protractor.webdriver_standalone);
gulp.task('run-prot', function () {
console.log('About to run the specs...........')
gulp.src(['ConvertedJSFiles/specs/*.js']).pipe(protractor.protractor({
configFile: 'ConvertedJSFiles/config/config.js'
})).on('error',function(e){
throw e;
});
});
console.log(protractor.getProtractorDir() + ' is the protractor directory ***');
控制台错误
F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build>gulp run-prot
F:\Selenium2\Protractor\TypeScriptProject\node_modules\.bin is the protractor directory ***
[18:16:17] Using gulpfile F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\gulpfile.js
[18:16:18] Starting 'run-prot'...
About to run the specs...........
[18:16:18] Finished 'run-prot' after 106 ms
[18:16:20] E/configParser - Error code: 105
[18:16:20] E/configParser - Error message: failed loading configuration file ConvertedJSFiles/config/config.js
[18:16:20] E/configParser - Error: Cannot find module 'F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\Convert
edJSFiles\config\config.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ConfigParser.addFileConfig (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\configParser.js:125:
26)
at Object.initFn [as init] (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\launcher.js:93:22)
at Object.<anonymous> (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\cli.js:112:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\gulpfile.js:11
throw e;
^
Error: protractor exited with code 105
问题是错误的目录引用。我用 "path" 包调试了它。下面是更新后的文件。
import * as gulp from 'gulp';
import * as protractor from 'gulp-protractor';
import * as path from 'path';
gulp.task('webdriver-update', protractor.webdriver_update);
gulp.task('webdriver-standalone', protractor.webdriver_standalone);
gulp.task('run-prot', function () {
console.log('About to run the specs...........')
let srcfiles=path.resolve('../specs/*.js');
console.log(srcfiles);
gulp.src([srcfiles]).pipe(protractor.protractor({
configFile: '../config/config.js'
})).on('error',function(e){
throw e;
});
});
console.log(protractor.getProtractorDir() + ' is the protractor directory ***');