小编JGl*_*son的帖子

我可以在没有“@std/esm”库的情况下将 NYC 与 ESM 和 Mocha 一起使用吗

我在一家@std/esm未获批准的公司工作。我的摩卡测试是这样工作的......

// suite.js
async function wire(){
    await import("./Sanity.spec.mjs"); // eslint-disable-line
    run();
}
wire();

//Sanity.spec.mjs
import chai from "chai"

describe("My Test", ()=>{
    it("Should do what I want", ()=>chai.assert.equal(1,1, "One is in fact 1")); // eslint-disable-line no-self-compare
});
Run Code Online (Sandbox Code Playgroud)

但是当我运行时,nyc mocha --delay --exit ./test/suite.js我看到 mocha 测试运行但代码覆盖率结果为空。

  My Test
    ? Should do what I want

  When using base App
info: Healthcheck server is listening on 420
    ? App should not be null
    ? The port should be correct


  3 passing …
Run Code Online (Sandbox Code Playgroud)

mocha.js istanbul nyc

8
推荐指数
0
解决办法
282
查看次数

使用react-router-dom时如何避免“无法给功能组件提供引用”?

我有以下内容(使用Material UI)...

import React from "react";
import { NavLink } from "react-router-dom";
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
function LinkTab(link){
    return <Tab component={NavLink}
        to={link.link}
        label={link.label}
        value={link.link}
        key={link.link}
    />;
}
Run Code Online (Sandbox Code Playgroud)

在新版本中,这会导致以下警告...

警告:不能为功能组件提供参考。尝试访问此引用将失败。您是要使用React.forwardRef()吗?

检查的渲染方法ForwardRef。在NavLink中(由ForwardRef创建)

我尝试更改为...

function LinkTab(link){
    // See https://material-ui.com/guides/composition/#caveat-with-refs
    const MyLink = React.forwardRef((props, ref) => <NavLink {...props} ref={ref} />);
    return <Tab component={MyLink}
        to={link.link}
        label={link.label}
        value={link.link}
        key={link.link}
    />;
}
Run Code Online (Sandbox Code Playgroud)

但是我仍然得到警告。我该如何解决这个问题?

reactjs react-router material-ui

7
推荐指数
6
解决办法
1505
查看次数

为什么升级到 Tomcat 10.0.5 会导致 spring boot 启动后关闭?

我有一个 Spring Boot 项目,我尝试使用嵌入的 Tomcat 10 而不是 Tomcat 7。我将以下内容添加到我的 POM 中...

<properties>
    <tomcat.version>10.0.5</tomcat.version>
    ...
</properties>
Run Code Online (Sandbox Code Playgroud)

然后我运行之前运行的相同命令......

mvn clean package -U && java -cp target\my.jar;props -Dloader.main=com.my.Main org.springframework.boot.loader.PropertiesLauncher
Run Code Online (Sandbox Code Playgroud)

但现在它刚刚启动,然后就自行关闭了。最后的消息是...

2021-05-13 15:35:42.105  INFO 10084 --- [           main] com.my.Main                   : Started Main in 42.918 seconds (JVM running for 44.009)
2021-05-13 15:35:42.190  INFO 10084 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
Run Code Online (Sandbox Code Playgroud)

为什么会发生这种情况以及如何升级而不产生这种副作用?

tomcat spring-boot tomcat10

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

获取 ChromeDriver 安装失败“未找到中央目录记录签名的结尾”

当我尝试运行 npm install chromedriver 我得到...

ChromeDriver installation failed Error extracting archive: Error: end of central directory record signature not found
Run Code Online (Sandbox Code Playgroud)

好像和这个差不多。

selenium-chromedriver

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

使用ESM时,如何使Istanbul识别代码覆盖率?

我正在使用ESM进行模块加载,然后像这样运行它们...

// More info on why this is needed see (https://github.com/mochajs/mocha/issues/3006)
async function wire(){
    await import("./Sanity.spec.mjs"); 
    await import("./Other.spec.mjs");
    run();
}
wire();
Run Code Online (Sandbox Code Playgroud)

然后我像这样运行这些测试nyc mocha --delay --exit ./test/suite.js。但是当我运行Istanbul时,似乎无法识别我的进口货,因此无法提供承保范围信息...

  3 passing (14ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|
Run Code Online (Sandbox Code Playgroud)

我如何才能使Istanbul识别ESM加载的代码?

mocha.js ecma istanbul es6-module-loader

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

Cassandra-Driver 4.x 中的 localDataCenter 我应该使用什么

当我使用cassandra-driver3.x 版本时,一切正常。现在我已经升级了,我收到以下消息...

错误:ArgumentError:“localDataCenter”未在客户端选项中定义,也未在构造函数中指定。至少需要一个。

我的客户声明看起来像这样......

const client = new Client({
        contactPoints: this.servers,
        keyspace: "keyspace",
        authProvider,
        sslOptions,
        pooling: {
            coreConnectionsPerHost: {
                [distance.local]: 1,
                [distance.remote]: 1
            }
        },
        // TODO: Needed because in spite of the documentation provided by DataStax the default value is not 0
        socketOptions: {
            readTimeout: 0
        }
});
Run Code Online (Sandbox Code Playgroud)

localDataCenter 属性应该使用什么?

cassandra cassandra-driver

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

即使使用限定符,两个具有相同类名(不同包)的 Spring Service Bean 也会抛出错误

我有以下...

package package1;

@Service
@Qualifier("kb")
public class UserService {
...
}

package package2;

@Service
@Qualifier("user")
public class UserService {
...
}

@Autowired
@Qualifier("user")
package2.UserService p2;
@Autowired
@Qualifier("kb")
package1.UserService p1;
Run Code Online (Sandbox Code Playgroud)

但是当我尝试运行它时,我得到...

org.springframework.beans.factory.BeanDefinitionStoreException:无法解析配置类[boot.Application];嵌套异常是 org.springframework.context.annotation.ConflictingBeanDefinitionException:bean 类 [package1.UserService] 的注释指定的 bean 名称“userService”与相同名称和类 [package2.UserService] 的现有不兼容 bean 定义冲突

我如何拥有 2 个同名的服务?

java spring spring-boot

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

在 Windows 上使用 Gradle Exec 任务时,Webpack“不是有效的 Win32 应用程序”

我每有以下gradle这个任务...

task webpack(type: Exec) {
    commandLine "./node_modules/.bin/webpack"
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试运行时,gradle webpack我得到以下...

Caused by: java.io.IOException: Cannot run program "./node_modules/.bin/webpack"
 (in directory "H:\Code\moxie_db_jpa"): CreateProcess error=193, %1 is not a val
id Win32 application
        at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(Def
aultProcessLauncher.java:25)
        ... 5 more
Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32
 application
        ... 6 more
Run Code Online (Sandbox Code Playgroud)

如果我运行.\node_modules\.bin\webpack一切正常。

gradle webpack

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

尝试运行 webpack 打包节点项目时,为什么会出现“TypeError: Class extends value undefined is not a constructor or null”

我有一个从 webpack 导入的简单应用程序。导入的项目导出一个这样的类......

export class BaseApp{...}

import { BaseApp } from "./MyClass"
import OtherThing from "./Other"
....
export { BaseApp, OtherThing }
Run Code Online (Sandbox Code Playgroud)

接下来我尝试在另一个节点/快递项目中扩展它......

import { BaseApp } from "@mine/util";

export class FullApp extends BaseApp{... }
Run Code Online (Sandbox Code Playgroud)

我得到...

class FullApp extends _mine_util__WEBPACK_IMPORTED_MODULE_0__["BaseA
pp"]{
                                                                         ^

TypeError: Class extends value undefined is not a constructor or null
Run Code Online (Sandbox Code Playgroud)

如何扩展从 Webpack 导入的类?

此处更新是一个演示该问题的示例项目...

https://github.com/jrgleason/simple-webpack-node

node.js ecmascript-6 webpack

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