Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions constantsAndTestData/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This class was created to constants, variables with values that don't change after being instantiated.
// It also helps in reducing duplicate code.


// Constants
export const APP_URL = "https://magento.softwaretestingboard.com/";

export const API_ENDPOINT = "https://z3.martioli.com/api/";
export const API_GET_ENTRY = "/id/%s"
34 changes: 19 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.40.0",
"@playwright/test": "^1.46.1",
"@types/node": "^20.9.3"
}
}
7 changes: 5 additions & 2 deletions pages/home.page.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { APP_URL } from './constants';


export class HomePage {

constructor(page) {
this.page = page;
this.homePageUrl = 'https://magento.softwaretestingboard.com/';
this.homePageUrl = APP_URL;
}

// locators
Expand All @@ -11,5 +14,5 @@ export class HomePage {
async navigateToHomePage() {
await this.page.goto(this.homePageUrl);
}
}

}
15 changes: 15 additions & 0 deletions tests/api/requests/apiClient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios';
import { API_ENDPOINT} from './constants';
import { APP_URL } from './constants';

const apiClient = {
get: async(config = {}) => {
try{
const response = await axios.get(`${API_ENDPOINT}${APP_URL}`, config)
return response.data;
} catch(error) {
console.error('GET Request Failed', error);
throw error;
}
}
}
17 changes: 17 additions & 0 deletions tests/api/testCases/apiTests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import apiClient from './tests/api/requests/apiClient.js';
import {test, expect} from '@playwright/test';

async function fetchdata() {
try{
const data = await apiClient.get('endpoint');
console.log(data);
} catch (error) {
console.error('Error fetching data: ', error);
}
}

test("API GetAll", async () => {

await fetchdata();

})