我在一家@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) 我有以下内容(使用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)
但是我仍然得到警告。我该如何解决这个问题?
我有一个 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)
为什么会发生这种情况以及如何升级而不产生这种副作用?
当我尝试运行 npm install chromedriver 我得到...
ChromeDriver installation failed Error extracting archive: Error: end of central directory record signature not found
Run Code Online (Sandbox Code Playgroud)
好像和这个差不多。
我正在使用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加载的代码?
当我使用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 属性应该使用什么?
我有以下...
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 个同名的服务?
我每有以下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一切正常。
我有一个从 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 导入的类?
此处更新是一个演示该问题的示例项目...
istanbul ×2
mocha.js ×2
spring-boot ×2
webpack ×2
cassandra ×1
ecma ×1
ecmascript-6 ×1
gradle ×1
java ×1
material-ui ×1
node.js ×1
nyc ×1
react-router ×1
reactjs ×1
spring ×1
tomcat ×1
tomcat10 ×1