gpt4 book ai didi

Angular 8 ng 测试 Web Worker 失败,返回 "Module scripts are not supported on DedicatedWorker yet"

转载 作者:行者123 更新时间:2023-12-02 14:49:00 31 4
gpt4 key购买 nike

使用 Angular CLI 创建一个新项目并生成一个 web-worker 并进行测试。

ng new demo
ng generate web-worker app
ng test --browsers=ChromeHeadless

获取错误:

TypeError: Failed to construct 'Worker': Module scripts are not supported on DedicatedWorker yet. You can try the feature with '--enable-experimental-web-platform-features' flag (see https://crbug.com/680046)

将“--enable-experimental-web-platform-features”添加到命令行失败并显示“未知选项”。是否可以将“enable-experimental-web-platform-features”作为标志传递或有条件地配置它?

最佳答案

我找到了解决方案。在脚本之后的“测试”部分的 angular.json 中:[] 需要像构建部分一样添加 webWorkerTsConfig 字段:

"webWorkerTsConfig": "tsconfig.worker.json"

我的“测试”部分现在看起来像(这是一个空项目):

        "test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [],
"webWorkerTsConfig": "tsconfig.worker.json"
}
},

希望,能帮到你:)

关于Angular 8 ng 测试 Web Worker 失败,返回 "Module scripts are not supported on DedicatedWorker yet",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56895037/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com