标签: e2e-testing

在Protractor中的httpBackend API模拟模块中打印请求

我在量角器中使用角度服务$ httpBackend对模拟的API运行我的e2e测试.

我已经有了selenium浏览器的调试日志:

afterEach(function() {
  browser.manage().logs().get('browser').then(function(browserLog){
    if(browserLog.length) {
      for (var i = 0; i < browserLog.length; i++) {
        if( typeof browserLog[i] !== 'undefined') {
          console.log(
            JSON
            .parse(browserLog[i].message).message.parameters[0].value
          );
        }
      };
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

我想在我的httpBackend模块中打印每个请求的URL标题(例如,对于用户资源):

$httpBackend
  .whenGET(/^\/api\/users.*$/)
  .respond(function(method, url, data, headers) {
     var users = mockUserService.getData();
     console.log(url);
     console.log(headers);
     return [200, users, {}];
});
Run Code Online (Sandbox Code Playgroud)

但是在httpBackend模块内的任何地方都没有记录任何内容.当我在我的应用程序中使用它时它工作正常,但是当我在量角器中使用它时它没有.

有没有办法在任何地方打印?即使在输出文本文件中?

angularjs protractor httpbackend ngmocke2e e2e-testing

7
推荐指数
1
解决办法
1192
查看次数

茉莉花规格超时了.重置WebDriver控制流 - 重定向到新页面

我是e2e测试中的床主,有问题.当我登录时 - 我从login.php重定向到index.php页面.但是我的测试失败并出现以下错误:

..A Jasmine spec timed out. Resetting the WebDriver Control Flow.
F

Failures:
1) Login Page should login and redirect to overview page with CR Operators rights
  Message:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  Stack:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

3 specs, 1 failure
Run Code Online (Sandbox Code Playgroud)

我的代码:

it('should login and redirect to overview page with CR Operators rights', function(sync) {
    element(by.model('username')).clear().sendKeys('testuser');
    element(by.model('password')).clear().sendKeys('test');
    element(by.css('[type="submit"]')).click();
    expect(browser.getLocationAbsUrl()).toMatch('/overview');
}); …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-e2e protractor e2e-testing

7
推荐指数
2
解决办法
1万
查看次数

量角器如何首先运行登录测试脚本

我试图用量角器测试Angular单页应用程序.我需要先运行登录脚本.只有这样我才能转移到其他路线,因为localStorage路线更换时会检查令牌.

这种测试方法是否正确?在这种情况下,我需要先运行登录脚本.量角器是否允许控制spec文件顺序.

或者我应该通过硬编码令牌来独立运行每个脚本localStorage(我应该在每次测试之前独立登录api调用).

我的登录脚本包含以下内容

it('Login with wrong email', function() {

})

it('Login with correct email', function() {

})
Run Code Online (Sandbox Code Playgroud)

因此,在运行之后,Login with correct mail我将获得将存储在localStorage中的accessToken,并且我可以继续测试其他路由.这是正确的方法吗?如果不是如何通过端到端登录测试单个应用程序.

在量角器样式指南中,它被称为

使您的测试彼此独立

因此,我应该beforeAll, beforeEach在每次测试之前使用获取访问令牌并存储在localStorage中.在那种情况下,请解释我如何做到这一点.

任何帮助是极大的赞赏.

谢谢.

angularjs angularjs-e2e protractor e2e-testing gulp-protractor

7
推荐指数
1
解决办法
1万
查看次数

bazel - 测试运行时的可写归档路径

我正在使用一些 bazel 测试目标(scala 风格java_test)运行 E2E 测试。

在 Maven 中,我曾经将日志转储到target/logs在测试期间创建的文件夹,然后如果出现故障 - 我可以查看该文件夹并找到日志。

在 bazel 中 - 我可以在我的测试日志配置中放入什么路径,以便在测试完成/测试失败时可以写并且方便地使用它?


我知道该java.io.tmp目录是可写的,但在测试完成后立即被删除。

java e2e-testing bazel

7
推荐指数
1
解决办法
1340
查看次数

jasmine2:如何处理失败 beforeAll

我的 jasmine2/protractor 测试看起来像这样

var testUserId = null;

describe("user test", function() {
  beforeAll(function(done) {
    createTestUser().
      .then(function(userId){testUserId = userId})
      .then(done)
      .catch(done.fail);

  it("should do stuff with the test user", function(done) {
    // bla bla
  });

  afterAll(function(done) {
    deleteTestUser(testUserId).
      .then(done)
      .catch(done.fail);
  });

})
Run Code Online (Sandbox Code Playgroud)

createTestUser 和 deleteTestUser 返回承诺。如果出现问题,他们会拒绝并显示错误消息。可能现在的问题是,即使在 beforeAll 中发生错误,测试也会开始。我得到

Failures:
1) should do stuff with the test user
Message: [my error message from beforeAll]
Run Code Online (Sandbox Code Playgroud)

如果有很多测试,它会尝试执行所有测试并失败并显示非常相同的错误消息。如果 beforeAll 函数失败,是否可以阻止它执行测试?

谢谢!

(“茉莉花核心”:“2.8.0”,“量角器”:“5.2.1”)


编辑:

这不完全是我所要求的,但至少我找到了一个解决方案来保持错误消息的数量,如下所示:

var testUserId = null;
describe("user test", function() {
  beforeAll(function(done) {
    createTestUser().
      .then(function(userId){testUserId = …
Run Code Online (Sandbox Code Playgroud)

javascript jasmine protractor e2e-testing

7
推荐指数
1
解决办法
2948
查看次数

如何使用cypress选择文本[cypress]

我正在寻找使用 Cypress测试像https://github.com/brijeshb42/medium-draft这样的文本编辑器。但是我找不到使用它选择文本的方法。有没有人知道如何做到这一点?

我必须选择一个特定的文本范围才能使测试有效。

javascript tdd integration-testing e2e-testing cypress

7
推荐指数
1
解决办法
5090
查看次数

如何获取RequestLogger的json响应

请求记录器

在主测试控制器之外进行此测试,使用页面模型配方。

/**
  Used to get the periodic analytic id.
  Whenever we are viewing an asset, the server must respond with an id.
  This id is later used by the client, to send periodic analytics.

  @param {object} t          Testcafe's test controller
  @param {object} logger     A testcafe's RequestLogger.
  @returns {string}          Returns the periodic analytic id.
*/
async getPeriodicAnalyticId(t, logger) {
  const logPrefix = 'Get periodic analytic id > ';
  let responseBody;

  await t
    .expect(logger.requests.length).gt(0, logPrefix + 'No …
Run Code Online (Sandbox Code Playgroud)

testing automated-tests node.js e2e-testing testcafe

7
推荐指数
1
解决办法
2086
查看次数

有没有办法访问剪贴板内容?

我正在测试一个页面,该页面具有一个带有嵌入代码的文本框和一个“复制”按钮,该按钮应该将文本框的内容复制到剪贴板上,以便用户可以将其粘贴到其他地方。有没有办法测试单击“复制”按钮并验证剪贴板内容是否与文本框的内容匹配?谢谢!

clipboard automated-tests e2e-testing testcafe

7
推荐指数
1
解决办法
2466
查看次数

从 Jenkins 管道中找不到获取 Microsoft.Data.Tools.Schema.SqlTask​​s.targets

我收到这个错误

The imported project "C:\Program Files\dotnet\sdk\6.0.101\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\6.0.101\\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" is correct, and that the file exists on disk.

Run Code Online (Sandbox Code Playgroud)

运行 E2E 测试时,将使用 DACPAC 创建数据库。我正在使用此命令来运行我的 e2e 测试项目

dotnet test "%workspace%\test\SampleProjectE2E\SampleProjectE2E.csproj"
Run Code Online (Sandbox Code Playgroud)

我已经在谷歌上查过了。我得到的答案是在构建服务器中安装SSDT。不确定这是否有效。请帮忙。

c# dacpac e2e-testing

7
推荐指数
1
解决办法
4202
查看次数

Nestjs e2e 测试没有记录器输出

我在开发过程中使用 NestJS 中的默认内置记录器形成简单的日志记录。但是当我运行 e2e 测试时,控制台上没有记录器输出。确实需要这个,看看测试失败时会发生什么。package.json 中的片段:

"test:e2e": "jest --config ./test/jest-e2e.json"

和 jest-e2e.json:

{
  "moduleFileExtensions": ["js", "json", "ts"],
  "rootDir": ".",
  "testEnvironment": "node",
  "testRegex": ".e2e-spec.ts$",
  "transform": {
    "^.+\\.(t|j)s$": "ts-jest"
  },
  "verbose": true
}
Run Code Online (Sandbox Code Playgroud)

logging e2e-testing nestjs

7
推荐指数
3
解决办法
3274
查看次数