問題タブ [angular8]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angular - 単体テスト: ウィンドウ オブジェクトの innerWidth プロパティを Angular + Jasmine でモックするにはどうすればよいですか?
ウィンドウの値に応じて、変数に特定の値が含まれることを期待する単体テストを作成したいと考えてinnerWidth
います。
私の単体テストでは、を使用しますwindow.innerWidth = 1000;
。ただし、というエラーが表示されますCannot assign to 'innerWidth' because it is a read-only property.
。
コード (home.component.spec.ts):
innerWidth
プロパティをモックする方法はありますか?
javascript - ngx-bootstrapモーダルウィンドウのウィンドウとドキュメントオブジェクトをモックする方法
Angular 8、Angular Universe、ngx-bootstrap を使用してサーバー側のレンダリングをセットアップすると、エラーが発生します
エラー ReferenceError: ドキュメントは ModalContainerComponent.ngOnInit (/Users/user/project/dist/server.js:243925:9) で定義されていません。 checkAndUpdateNodeInline (/Users/user/project/dist/server.js:31788:20) で checkAndUpdateNode (/Users/user/project/dist/server.js:31750:16) で prodCheckAndUpdateNode (/Users/user/project/dist) で/server.js:32291:5) Object.updateDirectives (/Users/user/project/dist/server.js:137344:457) で Object.updateDirectives (/Users/user/project//server.js:32079: 72) Object.checkAndUpdateView (/Users/user/project//server.js:31732:14) で ViewRef_.detectChanges (/Users/user/project//server.js:23119:22) で ComponentLoader.show (/ユーザー/ユーザー/プロジェクト//server.js:241722:50)
サーバーファイルでドミノを使用しようとしましたが、役に立ちませんでした
server.ts