4

我正在尝试使用webdriverIO对 API 进行自动测试而没有任何结果,也尝试使用chaichai-http使用webdriverIO,但还没有。有什么线索吗?

这是我写的:

  var chai = require('chai');
  var chaiHttp = require('chai-http');
  global.expect = chai.expect;
  chai.Should();
  chai.use(chaiHttp);

  var username = 'salvador.salvatierra@alegra.com';
  var token = 'a5ff7f1063582fd0140d';

  describe('Se consulta a la lista de contactos a traves de la API rest', 
 function(){

   it('Se hace un request GET al endpoint /contacts', function(){

    chai.request('https://app.alegra.com/api/v1/contacts')
    .get('/')
    .set('Accept','application/json')
    .query({limit:'10', order_direction: 'DESC', order_field: 'id'})
    .auth(username,token)
    .then(function(res){
        console.log(res);
        res.should.have.status(200);
        res.body.should.be.a.json;
    })
    .catch(function (err){
        setTimeout(function(){
            throw new err;
        });         
    })      
});

});

更新
我正在使用webdriverIOwithmocha和. 我运行它的方式是通过命令,而我使用的浏览器命令是. 我想达到的终点是chaichai-http.\node_modules\.bin\wdio wdio.conf.js --spec .\test\specs\test\get_test.jsbrowser.url('/invoices')https://app.alegra.com/api/v1/contacts/

这是我的package.json

 {
  "name": "web-test",
  "version": "1.0.0",
  "description": "\"# Alegra webdriverIO tests\"",
  "main": "index.js",
  "dependencies": {},
  "devDependencies": {
    "body-parser": "^1.17.2",
    "chai": "^4.1.1",
    "chai-http": "^3.0.0",
    "chai-webdriverio": "^0.4.2",
    "express": "^4.15.4",
    "supertest": "^3.0.0",
    "wdio-dot-reporter": "0.0.8",
    "wdio-mocha-framework": "^0.5.11",
    "wdio-selenium-standalone-service": "0.0.8",
    "wdio-spec-reporter": "^0.1.2",
    "webdriverio": "^4.8.0"
   },
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "author": "Salvador Salvatierra",
   "license": "ISC",
   "directories": {
     "test": "test"
   },
   "repository": {
   "type": "git",
   "url": "git+https://ssalvatierra@bitbucket.org/ssalvatierra/alegra-wdio.git"
   },
  "keywords": [
    "alegra",
    "test",
    "webdriverio"
  ],
  "homepage": "https://bitbucket.org/ssalvatierra/alegra-wdio#readme"
  }
4

0 回答 0