小编Ga *_*chi的帖子

为什么从生产中的代码库中删除 QA ID

在我们正在开发的 React 应用程序中,我们使用 QA ID 进行 Selenium 测试。

将它们留在生产(实时)的代码库中是一种不好的做法吗?

如果是这样,为什么?难道只是为了尽量保持 TTFB(第一个字节的时间)低吗?


更多背景:

  • 用于自动化标签的实用程序,它接受给定的字符串并返回一个包含要传播到元素上的属性的对象。这些只能用于测试目的,因为它们只能在测试运行期间可用。

例如。

const automationTags = (givenTag) =>
  (IS_PROD || !givenTag) ? {} : { 'data-qa': _.kebabCase(givenTag) }
Run Code Online (Sandbox Code Playgroud)

用法:

  • <Component {...automationTags(`${dataQa}-button`)} />
  • <Component {...automationTags('profile-page-success-btn')} />

... dataQaReact 组件中使用的 prop 在哪里。

html testing selenium reactjs

4
推荐指数
1
解决办法
918
查看次数

Mockito - 无法在HttpEntity上初始化间谍

我正在测试的代码工作正常,日志是正确的.


测试错误:ConnectorTest:无法初始化@Spy带注释的字段'entity'.


  • 为什么我不能在http实体上使用verify?
  • 有没有更好的方法来测试它?我应该监视日志吗?

要测试的类别:

public class Connector {

    private static final String hostname = "localhost";
    private int varnishPort = 8000;

    private int connectionTimeout = 5000; //millis
    private int requestTimeout = 5000;
    private int socketTimeout = 5000;

    private final HttpHost host;
    private HttpClient httpClient;
    private HttpEntity entity;
    private HttpResponse response;

    public Connector(){

        host = new HttpHost(this.hostname, this.varnishPort);

        RequestConfig.Builder requestBuilder = RequestConfig.custom();
        requestBuilder = requestBuilder.setConnectTimeout(connectionTimeout);
        requestBuilder = requestBuilder.setConnectionRequestTimeout(requestTimeout);
        requestBuilder = requestBuilder.setSocketTimeout(socketTimeout);

        HttpClientBuilder builder = HttpClientBuilder.create();     
        builder.setDefaultRequestConfig(requestBuilder.build());
        httpClient = builder.build();
    }


    public …
Run Code Online (Sandbox Code Playgroud)

unit-testing varnish mockito apache-httpclient-4.x

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

HTTP方法PURGE是否在Varnish中是幂等的?

HTTP动词PURGE是幂等的吗?如果我两次发送相同的PURGE请求,第二次会收到200吗?

我有一个微服务,可在将消息发布到Rabbit队列之前使Varnish缓存无效。在清除失败的情况下,我们需要记录并继续执行。

队列使用者必须从Varnish缓存中获取资源的最新状态。如果第一个微服务的第一次清除成功,是否会成功返回第二个微服务的新清除请求(实际从清漆请求资源之前)?

varnish purge http-method rabbitmq microservices

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

具有映射诊断上下文的Golang日志记录

如何在GoLang中实现 MDC日志记录(Java)?

我需要在所有服务器日志中添加UUID,以便能够跟踪并发请求。

go mdc

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

正则表达式从缩小中排除 npm 库

我必须为 websockets(扩散)使用非开源发布/订阅库,并且必须坚持使用特定版本,因为它是在服务器端使用的,我无法控制它。

问题是,在他们的代码库中的一个单独的 util 中,他们使用了保留关键字interface并触发了一个破坏构建的缩小错误:

Failed to minify the code from this file: 

    ./node_modules/babel-loader/lib??ref--6-oneOf-2!./node_modules/diffusion/src/node_modules/util/interface.js:127 

    Read more here: bit.ly/CRA-build-minify
Run Code Online (Sandbox Code Playgroud)

我可以使用哪个正则表达式从缩小中排除此依赖项?

config.optimization.minimizer[0].options.exclude = /node_modules/; 不会将其排除在缩小之外。

config.optimization.minimizer[0].options.exclude = /^.*(node_modules|.js).*$/; 有效,但它太宽泛了


有关更多上下文,这是导致缩小失败的依赖项代码:

node_modules/diffusion/src/node_modules/util/interface.js

function _implements() {
  var args = Array.prototype.slice.call(arguments, 0);
  var impl = args.pop();
  var unsatisfied = [];
  ...

  // The joys of duck type. Quack quack
  args.forEach(function(interface) {          <<<<<<<<<<<<<<<<<<<<<
      unsatisfied = unsatisfied.concat(interface(impl));
  });
Run Code Online (Sandbox Code Playgroud)

这是 webpack 配置文件在我覆盖之前的样子:(我们不允许弹出)

"optimization": {
    "minimizer": [
      {
        "options": {
          "test": {

          },
          "extractComments": false, …
Run Code Online (Sandbox Code Playgroud)

javascript regex webpack push-diffusion

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

HAL - is it a violation to the HAL format/standard if links are in the main body?

According to the HAL standard (see here and here) the links to other resources should be placed in a specific embedded section.

So for instance this is not valid HAL, is my understanding correct?

{
  "movies": [
     {
       "id": "123",
       "title": "Movie title 1",
       "_links": {
           "subtitles": {
              "href": "/movies/123/subtitles"
           }
        }
     },{
       "id": "456",
       "title": "Movie title 2",
       "_links": {
           "subtitles": {
              "href": "/movies/456/subtitles"
           }
        }
     }
  ],
  "_links": {
      "self": {
         "href": "/movies"
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

The …

rest json hateoas discoverability hypermedia

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