编辑:我在 Angular 上打开了一个问题,他们更新了文档:https : //github.com/angular/angular/issues/39740
在 Angular 测试中,通常的做法是对beforeEach
方法执行此操作
beforeEach(waitForAsync(() => {
TestBed
.configureTestingModule({
declarations: [BannerComponent],
})
.compileComponents(); // compile template and css
}));
Run Code Online (Sandbox Code Playgroud)
执行以下操作有什么区别?
beforeEach(async () => {
await TestBed
.configureTestingModule({
declarations: [BannerComponent],
})
.compileComponents(); // compile template and css
});
Run Code Online (Sandbox Code Playgroud)
我试图在文档中找到解释,但无法弄清楚。
https://angular.io/api/core/testing/waitForAsync#description https://v10.angular.io/guide/testing-components-scenarios#the-async-beforeeach
我找不到有关如何在 NodeJS(使用 Express)中为给定请求设置自定义超时的文档?
以下不起作用......:
https.get("https://externalurl.com", { timeout: 1000 }, (res) => {
resp.on("timeout", () => {
console.log("Never fired");
});
});
Run Code Online (Sandbox Code Playgroud)
这样做也不起作用:
https.get("https://externalurl.com", (req, res) => {
req.setTimeout(1000);
});
Run Code Online (Sandbox Code Playgroud)
这样做也不行...
https.get("https://externalurl.com", (res) => {
})
.setTimeout(1000);
Run Code Online (Sandbox Code Playgroud)
它总是等待超过 1 秒才抛出错误
有人可以帮忙吗?是否有“官方”方法来为给定请求设置自定义超时?
我的完整 server.ts
// Express server
const app = express();
const PORT = process.env.PORT || 80;
const DIST_FOLDER = join(process.cwd(), "dist/browser");
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {
AppServerModuleNgFactory,
LAZY_MODULE_MAP,
ngExpressEngine, …
Run Code Online (Sandbox Code Playgroud)