Wdio/TypeScript-在BitBucket管道中运行测试时找不到模块
我有一个项目webdrivero/typescript(使用页面对象),它打算在BitBucket管道上运行。 当我在本地运行测试时,所有测试都正常工作,但当我推到Bitbucket时,管道失败,所有测试都不会运行 BitBucket管道日志:Wdio/TypeScript-在BitBucket管道中运行测试时找不到模块,typescript,docker,webdriver-io,pageobjects,bitbucket-pipelines,Typescript,Docker,Webdriver Io,Pageobjects,Bitbucket Pipelines,我有一个项目webdrivero/typescript(使用页面对象),它打算在BitBucket管道上运行。 当我在本地运行测试时,所有测试都正常工作,但当我推到Bitbucket时,管道失败,所有测试都不会运行 BitBucket管道日志: [0-0]在chrome-/specs/login.spec.ts中运行 [0-0] https://automation-company.staging.singlecase.cz [0-0]2019-06-14T21:49:52.327Z错误@wdi
[0-0]在chrome-/specs/login.spec.ts中运行
[0-0] https://automation-company.staging.singlecase.cz
[0-0]2019-06-14T21:49:52.327Z错误@wdio/runner:错误:找不到模块'@Pages/LoginPage'
BitBucket-pipelines.yml
image: node:10.15.3
pipelines:
default:
- step:
script:
- apt update && apt install default-jre -y
- npm install
- echo "Run tests!"
- ENV='staging' HEADLESS=true npm test
services:
- selenium
definitions:
services:
selenium:
image: selenium/standalone-chrome
这里是wdio.conf.js
const timeout = process.env.DEBUG ? 99999999 : 90000;
let chromeArgs = ['--no-sandbox', "window-size=1920,1080", 'disable-infobars', 'disable-extensions', '--lang=en-us', '--disable-dev-shm-usage'];
if(process.env.HEADLESS === 'true') {
chromeArgs.push('--headless');
}
exports.config = {
runner: 'local',
host: 'localhost',
port: 4444,
specs: [
'./specs/login.spec.ts',
],
maxInstances: 2,
capabilities: [{
maxInstances: 2,
browserName: 'chrome',
'goog:chromeOptions': {
args: chromeArgs
}
}],
logLevel: 'error',
deprecationWarnings: true,
bail: 0,
baseUrl: serverURL,
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: ['selenium-standalone'],
framework: 'mocha',
mochaOpts: {
compilers: [
'tsconfig-paths/register'
],
ui: 'bdd',
retries: 2,
timeout: timeout
},
before: function () {
require('ts-node').register({ files: true });
console.log(browser.options.baseUrl);
},
最后是tsconfig.js文件
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@Specs/*": ["./specs/*"],
"@Pages/*": ["./src/pages/*"],
"@Helpers/*": ["./helpers/*"]
},
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
/* List of folders to include type definitions from. */
"types": ["@wdio/sync","mocha", "node"], /* Type declaration files to be included in compilation. */
// "types": ["webdriverio","mocha", "node"],
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
}
}
下面是我如何导入模块的示例:
从'@Pages/LoginPage'导入登录页面;
从“chai”导入{expect};
从“@Helpers/USERS”导入用户;
从“@Helpers/url”导入路径;
请记住,它在本地工作,在CI上失败。您能确认是否从CI工具调用了浏览器吗?我也有同样的问题。您解决了吗?您能确认是否从CI工具调用了浏览器吗?我也遇到了同样的问题。你解决了吗?