Skip to content
Merged
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
5 changes: 5 additions & 0 deletions types/amzn__synthetics-playwright/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { synthetics } from "@amzn/synthetics-playwright";
import type { Browser, BrowserContext, LaunchOptions, Page } from "@playwright/test";

export const handler = async () => {
const launchOptions: LaunchOptions = await synthetics.getDefaultLaunchOptions();
const browser: Browser = await synthetics.launch(launchOptions);
const page: Page = await synthetics.newPage(browser);

await page.goto("https://example.com");
await page.screenshot({ path: "/tmp/example.png" });

await synthetics.close();
};

export const runTestStep = <NextPage>(
stepName: string,
runTestsAndReturnNextPage: () => Promise<NextPage>,
): Promise<NextPage> => {
return synthetics.executeStep(stepName, async () => {
const nextPage = await runTestsAndReturnNextPage();
return nextPage;
});
};

export const testWithBrowserContext = async () => {
const browser: Browser = await synthetics.launch();
const context: BrowserContext = await browser.newContext();
const page: Page = await synthetics.newPage(context);

await page.goto("https://example.com");
await synthetics.close();
};

export const testExecuteStepWithConfig = async () => {
const browser: Browser = await synthetics.launch();
const page: Page = await synthetics.newPage(browser);

await synthetics.executeStep(
"test step",
async () => {
await page.goto("https://example.com");
return page.title();
},
{
continueOnStepFailure: true,
screenshotOnStepStart: true,
screenshotOnStepSuccess: false,
screenshotOnStepFailure: true,
},
page,
);

await synthetics.close();
};
30 changes: 30 additions & 0 deletions types/amzn__synthetics-playwright/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Browser, BrowserContext, BrowserType, LaunchOptions, Page } from "@playwright/test";

export interface StepConfig {
readonly continueOnHttpStepFailure?: boolean | undefined;
readonly continueOnStepFailure?: boolean | undefined;
readonly screenshotOnStepFailure?: boolean | undefined;
readonly screenshotOnStepStart?: boolean | undefined;
readonly screenshotOnStepSuccess?: boolean | undefined;
readonly stepDurationMetric?: boolean | undefined;
readonly stepsReport?: boolean | undefined;
readonly stepSuccessMetric?: boolean | undefined;
}

export interface SyntheticsType {
readonly close: () => Promise<void>;
readonly executeStep: <T>(
stepName: string,
func: () => Promise<T>,
stepConfig?: StepConfig,
page?: Page,
) => Promise<T>;
readonly getDefaultLaunchOptions: () => Promise<LaunchOptions>;
readonly getPage: (browser: Browser | BrowserContext) => Promise<Page>;
readonly launch: BrowserType["launch"];
readonly newPage: (browser: Browser | BrowserContext) => Promise<Page>;
}

export const synthetics: SyntheticsType;

export {};
22 changes: 22 additions & 0 deletions types/amzn__synthetics-playwright/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"private": true,
"name": "@types/amzn__synthetics-playwright",
"version": "10.0.9999",
"nonNpm": true,
"nonNpmDescription": "Library functions available for Node.js canary scripts using Playwright",
"projects": [
"https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html"
],
"devDependencies": {
"@types/amzn__synthetics-playwright": "workspace:."
},
"peerDependencies": {
"@playwright/test": "^1.53.0"
},
"owners": [
{
"name": "Andor Kovács",
"githubUsername": "kovacsandor"
}
]
}
19 changes: 19 additions & 0 deletions types/amzn__synthetics-playwright/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es2018"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"amzn__synthetics-playwright-tests.ts"
]
}
2 changes: 1 addition & 1 deletion types/expect-cookies/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/expect-cookies",
"version": "0.2.9999",
"version": "0.3.9999",
"projects": [
"https://github.com/gregl83/expect-cookies"
],
Expand Down