小编Dan*_*iel的帖子

Mocha Supertest json响应身体模式匹配问题

当我进行API调用时,我想检查返回的JSON的结果.我可以看到正文和一些静态数据正在被正确检查,但无论我在哪里使用正则表达式都会被破坏.这是我测试的一个例子:

describe('get user', function() {

    it('should return 204 with expected JSON', function(done) {
      oauth.passwordToken({
        'username': config.username,
        'password': config.password,
        'client_id': config.client_id,
        'client_secret': config.client_secret,
        'grant_type': 'password'
      }, function(body) {
        request(config.api_endpoint)
        .get('/users/me')
        .set('authorization', 'Bearer ' + body.access_token)
        .expect(200)
        .expect({
          "id": /\d{10}/,
          "email": "qa_test+apitest@example.com",
          "registered": /./,
          "first_name": "",
          "last_name": ""
        })
        .end(function(err, res) {
          if (err) return done(err);
          done();
        });
      });
    });
  });
Run Code Online (Sandbox Code Playgroud)

这是输出的图像:

在此输入图像描述

关于使用正则表达式进行模式匹配json body响应的任何想法?

regex api json mocha.js supertest

13
推荐指数
2
解决办法
7386
查看次数

使用 Android uiautomator 设置文本后抑制键盘

使用 uiautomator for Android 我可以在文本字段中设置文本,但无法关闭键盘。对于某些手机,当处于横向模式时,键盘会占据整个屏幕,必须点击“完成”才能退出该视图。如果我可以抑制键盘,那么我可以在横向和纵向运行 uiautomator 没有问题。

new UiObject(new UiSelector().text("Enter Text")).click();
new UiObject(new UiSelector().className("android.widget.EditText").instance(0)).setText("sample text");

// This is where I need to suppress the keyboard to view the app instead of just the keyboard itself.

new UiObject(new UiSelector().text("Submit")).click();
Run Code Online (Sandbox Code Playgroud)

提前致谢。

android android-uiautomator

5
推荐指数
2
解决办法
5783
查看次数

标签 统计

android ×1

android-uiautomator ×1

api ×1

json ×1

mocha.js ×1

regex ×1

supertest ×1