Skip to content

Commit 065b964

Browse files
committed
test: βœ… add first e2e test
1 parent a6d86aa commit 065b964

File tree

8 files changed

+54
-10
lines changed

8 files changed

+54
-10
lines changed

β€Žapps/404-recipe-filter-material-starter/e2e/example.spec.tsβ€Ž

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('/');
5+
await page.getByLabel('keywords').click();
6+
await page.getByLabel('keywords').fill('Bur');
7+
8+
await expect(page.getByRole('heading', { level: 2 })).toHaveText(['Burger']);
9+
await expect(page.getByRole('button', { name: 'ADD' })).toBeVisible();
10+
});

β€Žapps/404-recipe-filter-material-starter/playwright.config.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default defineConfig({
2525
/* Run your local dev server before starting the tests */
2626
webServer: [
2727
{
28-
command: 'npx nx serve 404-recipe-filter-material-starter',
28+
command: 'npx nx serve 404-recipe-filter-material-starter -c testing',
2929
url: 'http://localhost:4200',
3030
reuseExistingServer: true,
3131
cwd: workspaceRoot,

β€Žapps/404-recipe-filter-material-starter/project.jsonβ€Ž

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@
4545
"extractLicenses": false,
4646
"sourceMap": true,
4747
"namedChunks": true
48+
},
49+
"testing": {
50+
"buildOptimizer": false,
51+
"optimization": false,
52+
"extractLicenses": false,
53+
"sourceMap": true,
54+
"namedChunks": true,
55+
"fileReplacements": [
56+
{
57+
"replace": "{projectRoot}/src/environments/environment.ts",
58+
"with": "{projectRoot}/src/environments/environment.testing.ts"
59+
}
60+
]
4861
}
4962
},
5063
"defaultConfiguration": "production"
@@ -57,6 +70,9 @@
5770
},
5871
"development": {
5972
"buildTarget": ":build:development"
73+
},
74+
"testing": {
75+
"buildTarget": ":build:testing"
6076
}
6177
},
6278
"defaultConfiguration": "development",
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
import {
22
ApplicationConfig,
3+
inject,
4+
provideAppInitializer,
35
provideZonelessChangeDetection,
46
} from '@angular/core';
57
import { provideHttpClient } from '@angular/common/http';
8+
import { environment } from '../environments/environment';
9+
import { provideRecipeRepositoryFake } from './recipe/recipe-repository.fake';
10+
import { RecipeRepositoryFake } from './recipe/recipe-repository.fake';
11+
import { recipeMother } from './testing/recipe.mother';
612

713
export const appConfig: ApplicationConfig = {
8-
providers: [provideHttpClient(), provideZonelessChangeDetection()],
14+
providers: [
15+
provideHttpClient(),
16+
provideZonelessChangeDetection(),
17+
...(environment.useFakes
18+
? [
19+
provideRecipeRepositoryFake(),
20+
provideAppInitializer(() => {
21+
inject(RecipeRepositoryFake).setRecipes([
22+
recipeMother.withBasicInfo('Burger').build(),
23+
recipeMother.withBasicInfo('Salad').build(),
24+
]);
25+
}),
26+
]
27+
: []),
28+
],
929
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const environment = {
22
production: true,
3+
useFakes: false,
34
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const environment = {
2+
production: false,
3+
useFakes: true,
4+
};

β€Žapps/404-recipe-filter-material-starter/src/environments/environment.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
export const environment = {
66
production: false,
7+
useFakes: false,
78
};
89

910
/*

0 commit comments

Comments
Β (0)