新しい/既存の角度プロジェクトにサイプレスを加えます
3402 ワード
このブログ記事では、サイプレスを角度で設定する手順を示します.サイプレスは、@briebug/cypress-schematic または手動で.アップロードされたソースコードを見てくださいGithub
自動初期化@ briebug/サイプレス回路図 まず、アングルプロジェクトで次のコマンドを使用してサイプレスをインストールします
サイプレス/統合ディレクトリの下に新しいテストを作成します
マニュアル初期設定 まず、アングルプロジェクトで次のコマンドを使用してサイプレスをインストールします
自動初期化@ briebug/サイプレス回路図
npm i -D cypress
2 . cypressの初期化と設定@briebug/cypress-schematic プラグイン.これはcypressディレクトリを生成します.JSONとアップデートパッケージ.JSONファイルng add @briebug/cypress-schematic
This will ask to remove Protractor from project with prompt “Would you like to remove Protractor from the project?”, enter Y if want to do so.
サイプレス/統合ディレクトリの下に新しいテストを作成します
describe('Home Page Test', () =>{
beforeEach(function () {
cy.visit('/');
});it('Show Error If failed to show Welcome message', () =>
{
// Check if the word Welcome exists
cy.contains('Welcome');
// Visit Angular Website and Angular Blog
cy.contains('Learn Angular').click();
cy.contains('Angular Blog').click();
});
});
3 .次のコマンドを使用して、サイプレス/統合の下で作成されたテストを実行しますng e2e
ホームページe 2 eテストマニュアル初期設定
npm i -D cypress
2 .最小限のサイプレスを作成します.JSONファイルの下に示すようにホームディレクトリの下に{
"integrationFolder": "cypress/integration",
"baseUrl": "http://localhost:4200",
"env": {
"username": "username",
"password": "password"
}
}
プロジェクトディレクトリ内のサイプレス、サイプレス/統合ディレクトリを作成します.とtsconfigを作成します.サイプレスディレクトリの下のJSONファイル{
"extends": "../tsconfig.json",
"include": \["../node\_modules/cypress", "\*\*/\*.ts"\],
"compilerOptions": {
"sourceMap": false
}
}
サイプレス/統合ディレクトリの下に新しいテストを作成しますdescribe('Home Page Test', () =>{
beforeEach(function () {
cy.visit('/');
});it('Show Error If failed to show Welcome message', () =>
{
// Check if the word Welcome exists
cy.contains('Welcome');
// Visit Angular Website and Angular Blog
cy.contains('Learn Angular').click();
cy.contains('Angular Blog').click();
});
});
次のコマンドを使用して、サイプレス/統合の下で作成されたテストを実行しますng e2e
コードアップロードGithub 参考にReference
この問題について(新しい/既存の角度プロジェクトにサイプレスを加えます), 我々は、より多くの情報をここで見つけました https://dev.to/pavankjadda/add-cypress-to-new-existing-angular-project-63eテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol