量角器基本设置抛出“未找到测试”

时间:2019-08-23 20:17:39

标签: typescript jasmine protractor

量角器的新手,请协助进行基本设置。缺少了一些东西,只需要启动任何站点即可。

我尝试了所有解决方案,但一直遇到未找到测试的问题 webdriver-manager更新或启动等。

我尝试了google only selenium webdriver无法启动的问题。 /./*spec文件引发格式错误

snap

Protractor.config.js

exports.config = {
    framework: "jasmine",

    capabilities: {
        'browserName': 'chrome'
    },
    seleniumAddress: "http://localhost:4444/wd/hub",
    baseUrl: "https://www.google.com",
    directConnect: true,
    allScriptsTimeout:  900000,
    specs: [
        '../specs/testCalc.ts'
          // './e2e/sampledemo.spec.ts',

    ],
}

package.json

    {
          "name": "Demo",
          "version": "1.0.0",
          "description": "Test desc",
          "private": true,
          "author": "Tester",
          "license": "ISC",
          "main": "index.js",
          "dependencies": {
            "@types/jasmine": "^3.2.0",
            "webdriver-manager": "^12.1.6"
          },
          "scripts": {
            "tsc": "tsc",
            "pretest": "npm run tsc",
            "test": "protractor.config.js",
            "webdriver-update": "webdriver-manager update"
          },
          "devDependencies": {
            "@types/node": "^12.7.2",
            "@angular/cli": "7.3.8",
            "@angular/compiler-cli": "7.2.14",
            "@angular/language-service": "7.2.14",
            "@types/jasmine": "~3.4.0",
            "jasmine-core": "~3.4.0",
            "typescript": "^3.5.3",
            "protractor": "~5.1.1"
          }
    }

tsconfig

{
      "compilerOptions": {
        "outDir": "dist",
        "module": "commonjs",
        "target": "es6",

        "types":[
          "jasmine",
          "node",
          "jasmine-expect"
        ],
        "include": [
            "src/**/*"
        ],
        "exclude": [
            "node_modules",
            "**/*.spec.ts"
        ]
      }
}
(node:9068) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[16:02:43] W/driverProviders - Using driver provider directConnect, but also found extra driver provider parameter(s):
seleniumAddress
[16:02:43] I/launcher - Running 1 instances of WebDriver
[16:02:43] I/direct - Using ChromeDriver directly...
Started      
No specs found
Finished in 0.001 seconds  
[16:02:49] I/launcher - 0 instance(s) of WebDriver still running
[16:02:49] I/launcher - chrome #01 passed
Process finished with exit code 0

1 个答案:

答案 0 :(得分:0)

这是解决方案。我在e2e文件夹下创建了一个新的json文件tsconfig.e2e.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/e2e",
    "baseUrl": "./",
    "module": "commonjs",
    "target": "es6",
    "types": [
      "jasmine",
      "jasminewd2",
      "node",
      "selenium-webdriver"
    ]
  }
}

还在protractor.config.js中的行下面添加了

beforeLaunch() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });

}

更新package.json以解决我的问题

{
  "name": "testproj",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "webdriver-update": "webdriver-manager update"
  },
  "private": true,
  "dependencies": {
    "protractor": "5.1.2",
    "@angular/platform-browser": "^8.2.3",
    "@angular/platform-browser-dynamic": "^8.2.3",
    "atob": "^2.1.2",
    "config": "^3.2.2",
    "ngc": "1.0.0",
    "webdriver-manager": "^12.1.6",
    "moment": "^2.24.0"
  },
  "devDependencies": {
    "@angular/cli": "^8.3.0",
    "@angular/compiler-cli": "^8.2.3",
    "@angular/language-service": "^8.2.3",
    "@types/jasmine": "^3.4.0",
    "@types/jasminewd2": "^2.0.6",
    "@types/jquery": "^3.3.0",
    "@types/node": "^12.7.2",
    "codelyzer": "^5.1.0",
    "jasmine-core": "^3.4.0",
    "jasmine-expect": "^4.0.3",
    "protractor": "^5.4.2",
    "protractor-screenshoter-plugin": "^0.10.3",
    "ts-node": "^8.3.0",
    "typescript": "^3.5.3"

  }
}