Skip to content

Commit a50673b

Browse files
committed
Import path Shortening tsconfig.json
1 parent d9b6475 commit a50673b

19 files changed

+180
-281
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ npm run allureReport
176176
npx playwright show-trace trace.zip
177177
```
178178
19. You can change the Logging Message at Test Case/Test Step Level in CustomReporterConfig.ts file
179+
20. In `tsconfig.json` file in `paths` section we can re-assign the long path imports like '../../' to a variable which starts with '@' and then we can use it to shorten our import statements in respective file.
180+
In the below example wherever '../../pageFactory/pageRepository/' import statement is used we can replace it with '@pages'
181+
```JS
182+
"@pages/*":["pageFactory/pageRepository/*"]
183+
```
179184

180185
## Reports
181186

html-report.zip

-167 KB
Binary file not shown.

lib/BaseTest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { test as baseTest } from '@playwright/test';
2-
import { LoginPage } from '../pageFactory/pageRepository/LoginPage';
3-
import { MyAccountPage } from '../pageFactory/pageRepository/MyAccountPage';
4-
import { MyAddressesPage } from '../pageFactory/pageRepository/MyAddressesPage'
5-
import { MyPersonalInformationPage } from '../pageFactory/pageRepository/MyPersonalInformationPage';
2+
import { LoginPage } from '@pages/LoginPage';
3+
import { MyAccountPage } from '@pages/MyAccountPage';
4+
import { MyAddressesPage } from '@pages/MyAddressesPage'
5+
import { MyPersonalInformationPage } from '@pages/MyPersonalInformationPage';
66

77
const test = baseTest.extend<{
88
loginPage: LoginPage;

package-lock.json

Lines changed: 138 additions & 254 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222
"author": "Akshay Pai",
2323
"license": "MIT",
2424
"dependencies": {
25-
"@playwright/test": "^1.19.0",
25+
"@playwright/test": "^1.20.0",
2626
"@types/adm-zip": "^0.4.34",
2727
"@types/crypto-js": "^4.1.0",
2828
"@typescript-eslint/eslint-plugin": "^5.11.0",
2929
"@typescript-eslint/parser": "^5.11.0",
3030
"adm-zip": "^0.5.9",
3131
"cross-env": "^7.0.3",
3232
"crypto-js": "^4.1.1",
33-
"eslint": "^8.9.0",
33+
"eslint": "^8.11.0",
3434
"eslint-plugin-import": "^2.25.4",
3535
"exceljs": "^4.3.0",
3636
"experimental-allure-playwright": "0.0.3",
3737
"pg": "^8.7.3",
38-
"playwright": "^1.19.0",
39-
"typescript": "^4.5.5"
38+
"playwright": "^1.20.0",
39+
"typescript": "^4.6.2"
4040
}
4141
}

pageFactory/pageRepository/LoginPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { LoginPageObjects } from "../objectRepository/LoginPageObjects";
2-
import { WebActions } from "../../lib/WebActions";
1+
import { LoginPageObjects } from "@objects/LoginPageObjects";
2+
import { WebActions } from "@lib/WebActions";
33
import type { Page } from 'playwright';
44
import {testConfig} from '../../testConfig';
55

pageFactory/pageRepository/MyAccountPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { MyAccountPageObjects } from "../objectRepository/MyAccountPageObjects";
2-
import { WebActions } from "../../lib/WebActions";
1+
import { MyAccountPageObjects } from "@objects/MyAccountPageObjects";
2+
import { WebActions } from "@lib/WebActions";
33
import type { Page } from 'playwright';
44

55
let webActions: WebActions;

pageFactory/pageRepository/MyAddressesPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { MyAddressesPageObjects } from "../objectRepository/MyAddressesPageObjects";
2-
import { WebActions } from "../../lib/WebActions";
1+
import { MyAddressesPageObjects } from "@objects/MyAddressesPageObjects";
2+
import { WebActions } from "@lib/WebActions";
33
import type { Page } from 'playwright';
44

55
let webActions: WebActions;

pageFactory/pageRepository/MyPersonalInformationPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { MyPersonalInformationPageObjects } from '../objectRepository/MyPersonalInformationPageObjects'
2-
import { WebActions } from "../../lib/WebActions";
1+
import { MyPersonalInformationPageObjects } from '@objects/MyPersonalInformationPageObjects'
2+
import { WebActions } from "@lib/WebActions";
33
import type { Page } from 'playwright';
44

55
let webActions: WebActions;

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const config: PlaywrightTestConfig = {
3939
baseURL: testConfig[process.env.ENV],
4040

4141
//Browser Mode
42-
headless: true,
42+
headless: false,
4343

4444
//Browser height and width
4545
viewport: { width: 1500, height: 730 },

tests/api/GET.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APIActions } from '../../lib/APIActions';
1+
import { APIActions } from '@lib/APIActions';
22
import { test } from '@playwright/test';
33

44
const apiActions = new APIActions();

tests/api/POST.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APIActions } from '../../lib/APIActions';
1+
import { APIActions } from '@lib/APIActions';
22
import { test } from '@playwright/test';
33

44
const apiActions = new APIActions();

tests/db/DB.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { testConfig } from '../../testConfig';
2-
import { DBActions } from '../../lib/DBActions';
2+
import { DBActions } from '@lib/DBActions';
33
import { test } from '@playwright/test'
44

55
test('Connect to Postgres DB', async () => {

tests/devices/Emulation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { LoginPage } from "../../pageFactory/pageRepository/LoginPage";
2-
import { MyAccountPage } from "../../pageFactory/pageRepository/MyAccountPage";
1+
import { LoginPage } from "@pages/LoginPage";
2+
import { MyAccountPage } from "@pages/MyAccountPage";
33
import { test } from '@playwright/test';
44

55
test(`Verify My Personal Information.`, async ({ page }) => {

tests/functional/Login.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from '../../lib/BaseTest';
1+
import test from '@lib/BaseTest';
22

33
test(`Login to PHP travels.`, async ({ loginPage, myAccountPage }) => {
44
await loginPage.navigateToURL();

tests/functional/MyAddress.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from '../../lib/BaseTest';
1+
import test from '@lib/BaseTest';
22

33
// We can use Steps like in Cucmber format as shown below
44

tests/functional/MyPersonalDetails.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from '../../lib/BaseTest';
1+
import test from '@lib/BaseTest';
22

33
test(`@Smoke Verify My Personal Information.`, async ({ loginPage, myAccountPage, myPersonalInformationPage }) => {
44
await loginPage.navigateToURL();

tests/visualComparison/visualComparision.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { LoginPage } from "../../pageFactory/pageRepository/LoginPage";
2-
import { MyAccountPage } from "../../pageFactory/pageRepository/MyAccountPage";
1+
import { LoginPage } from "@pages/LoginPage";
2+
import { MyAccountPage } from "@pages/MyAccountPage";
33
import { expect, test } from '@playwright/test';
44

55
test(`Verify User Login.`, async ({ page }) => {

tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".", /* Specify the base directory to resolve non-relative module names. */
4+
"paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */
5+
"@pages/*":["pageFactory/pageRepository/*"],
6+
"@objects/*":["pageFactory/objectRepository/*"],
7+
"@lib/*":["lib/*"],
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)