小编Gre*_*000的帖子

在可视化代码中调试 Angular/Typescript 将“_1”附加到变量

我正在尝试在可视代码中调试角度/打字稿应用程序。假设我运行以下代码

try {
    ...
} catch (error) {
    console.log(error);
}
Run Code Online (Sandbox Code Playgroud)

假设发生错误,我将在控制台中看到正常执行时记录的错误。我面临的问题是,如果我在调试模式下运行相同的情况(“针对本地主机启动 Chrome”)。我会得到:

“未捕获的引用错误:错误未定义”

如果我在调试视图中查看“Closure”部分而不是“Local”部分。我可以访问error_其中确实包含正常执行中通常记录的内容。

有没有办法在角度/打字稿应用程序中查看错误而error不是在调试模式下?error_1

我尝试了 Typescript/babel import 的建议,导致“ _1.default is not a function,但没有成功。

错误预览

typescript visual-studio-code angular

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

模拟 org.springframework.web.reactive.function.client.WebClient.ResponseSpec#onStatus 输入参数

考虑以下代码:

    public Mono<Void> doStuff() {

        return this.requestStuff()
            .onStatus(HttpStatus::is5xxServerError,
                    clientResponse -> {
                    aMethodIWouldLikeToTest(clientResponse);
                    return Mono.error(new MyCustomException("First error I would like to test"));
                    })
            .onStatus(HttpStatus::is4xxClientError,
                    clientResponse -> {
                    aMethodIWouldLikeToTest(clientResponse);
                    return Mono.error(new MyCustomException("Second error I would like to test"));
                    })
            .bodyToMono(String.class)
            .flatMap(x -> anotherMethodIManagedToTest(x)))

    }
Run Code Online (Sandbox Code Playgroud)

我的第一个目标是测试anotherMethodIManagedToTest(x),这是使用以下方法实现的:

    import org.springframework.web.reactive.function.client.WebClient;

    ...

    @Mock
    private WebClient.ResponseSpec responseSpec;

    private String desiredInputParam = "There is another black spot on the sun today!";

    ...

    @Test
    public void allGood_anotherMethodIManagedToTest_success {

        ...

        ClassUnderTest classUnderTest = new classUnderTest()
        ClassUnderTest classUnderTestSpy = …
Run Code Online (Sandbox Code Playgroud)

java webclient mockito

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