Skip to content

Commit ebe548d

Browse files
authored
Feature/create test job (#8)
* add initial example workflow * update testing steps to yarn test * add checkout repo * add setup node js * add yarn install * rename test * change test text to correct value * add end to end tests * add playwright url for test env * add install playwright browser * fix: typo in localhost * test: add some logging * test: ci env variable * fix: make CI env variable empty * fix: unset CI env var, set by default in GithHub Actions * try without playwright browser * add pre commit tests * this is a test commit * change test comand * change when test runs * add initial example workflow * update testing steps to yarn test * add checkout repo * add setup node js * add yarn install * rename test * change test text to correct value * add end to end tests * add playwright url for test env * add install playwright browser * fix: typo in localhost * test: add some logging * test: ci env variable * fix: make CI env variable empty * fix: unset CI env var, set by default in GithHub Actions * try without playwright browser * add pre commit tests * this is a test commit * change test comand * change when test runs * change backstage url port in e2e test * Update test command in run-tests.yml * add testing section to readme
1 parent a2b3867 commit ebe548d

File tree

6 files changed

+62
-13
lines changed

6 files changed

+62
-13
lines changed

.github/workflows/run-tests.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test and E2E tests
2+
run-name: Run tests and E2E tests
3+
4+
on:
5+
push:
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
run-tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Use Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: '20'
18+
- run: yarn install
19+
- run: yarn backstage-cli repo test
20+
21+
run-e2e-tests:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4 #chekcout te repository
25+
- name: Use Node.js
26+
uses: actions/setup-node@v3 #setup node version 20
27+
with:
28+
node-version: '20'
29+
30+
- name: Install dependencies #install dependencies
31+
run: yarn install
32+
33+
- name: Run E2E tests
34+
env:
35+
PLAYWRIGHT_URL: http://localhost:3000 # set the URL of the app to test with playwright
36+
CI: # unset CI because it is set by default in Github actions
37+
run: |
38+
yarn test:e2e

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,17 @@ This file changes some base values that are necessary to build the correct image
298298
**`app-config.production.yaml`:**
299299
<br>
300300
This file adds one line to the kubernetes plugin setup, which is only needed if the app is hosted inside of a kubernetes cluster.
301+
302+
# Testing
303+
304+
Before committing your changes, run the tests pls. ✨
305+
306+
```sh
307+
yarn test
308+
```
309+
310+
to run tests without end to end testing run:
311+
312+
```sh
313+
yarn backstage-cli repo test
314+
```

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"tsc": "tsc",
1717
"tsc:full": "tsc --skipLibCheck false --incremental false",
1818
"clean": "backstage-cli repo clean",
19-
"test": "backstage-cli repo test",
19+
"test": "backstage-cli repo test && playwright test",
2020
"test:all": "backstage-cli repo test --coverage",
2121
"test:e2e": "playwright test",
2222
"fix": "backstage-cli repo fix",
@@ -31,6 +31,10 @@
3131
"docker:remove-all": "docker compose down",
3232
"new": "backstage-cli new --scope internal"
3333
},
34+
"pre-commit": [
35+
"yarn test",
36+
"yarn e2e-test"
37+
],
3438
"workspaces": {
3539
"packages": [
3640
"packages/*",
@@ -62,4 +66,5 @@
6266
"prettier --write"
6367
]
6468
}
69+
6570
}

packages/app/e2e-tests/app.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ import { test, expect } from '@playwright/test';
1919
test('App should render the welcome page', async ({ page }) => {
2020
await page.goto('/');
2121

22-
await expect(page.getByText('My Company Catalog')).toBeVisible();
22+
await expect(page.getByText('Scaffolded Backstage App')).toBeVisible();
2323
});

packages/app/src/App.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('App', () => {
1010
{
1111
data: {
1212
app: { title: 'Test' },
13-
backend: { baseUrl: 'http://localhost:7007' },
13+
backend: { baseUrl: 'http://localhost:3000' },
1414
techdocs: {
1515
storageUrl: 'http://localhost:7007/api/techdocs/static/docs',
1616
},

yarn.lock

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8915,7 +8915,8 @@
89158915
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
89168916
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==
89178917

8918-
"@types/react-dom@*", "@types/react-dom@^18.0.0":
8918+
"@types/react-dom@*", "@types/react-dom@^18", "@types/react-dom@^18.0.0":
8919+
"@types/react-dom@*", "@types/react-dom@^18", "@types/react-dom@^18.0.0":
89198920
version "18.2.19"
89208921
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.19.tgz#b84b7c30c635a6c26c6a6dfbb599b2da9788be58"
89218922
integrity sha512-aZvQL6uUbIJpjZk4U8JZGbau9KDeAwMfmhyWorxgBkqDIEf6ROjRozcmPIicqsUwPUjbkDfHKgGee1Lq65APcA==
@@ -8953,15 +8954,6 @@
89538954
dependencies:
89548955
"@types/react" "*"
89558956

8956-
"@types/react@*", "@types/react@^16.13.1 || ^17.0.0 || ^18.0.0":
8957-
version "18.2.56"
8958-
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.56.tgz#2d3e9021a0b6eb5bfc227761cc61b1c6dc6e0cd8"
8959-
integrity sha512-NpwHDMkS/EFZF2dONFQHgkPRwhvgq/OAvIaGQzxGSBmaeR++kTg6njr15Vatz0/2VcCEwJQFi6Jf4Q0qBu0rLA==
8960-
dependencies:
8961-
"@types/prop-types" "*"
8962-
"@types/scheduler" "*"
8963-
csstype "^3.0.2"
8964-
89658957
"@types/react@^16.13.1 || ^17.0.0":
89668958
version "17.0.75"
89678959
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.75.tgz#cffbc76840a12fcadaf5a3cf14878bb06efcf73d"

0 commit comments

Comments
 (0)