Skip to content

Commit 92087ad

Browse files
author
rocketraccoon
committed
feat(testplane): fixes
1 parent ca3ba6a commit 92087ad

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

docs/commands/browser/restoreState.mdx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,50 @@ it("test", async ({ browser }) => {
102102
});
103103
```
104104

105+
Example of implementing authentication in tests with saveState/restoreState and beforeAll hook.
106+
107+
```typescript
108+
import { ConfigInput, WdioBrowser } from "testplane";
109+
import { launchBrowser } from "testplane/unstable";
110+
111+
export default {
112+
gridUrl: "local",
113+
beforeAll: async ({ config }) => {
114+
const b = await launchBrowser(config.browsers["chrome"]!);
115+
116+
await b.url("https://our-site.com");
117+
await b.$("input.login").setValue("[email protected]");
118+
await b.$("input.password").setValue("password123");
119+
120+
await b.saveState({ path: "./.testplane/state.json" });
121+
await b.deleteSession();
122+
},
123+
sets: {
124+
/* ... */
125+
},
126+
browsers: {
127+
chrome: {
128+
headless: false,
129+
desiredCapabilities: {
130+
browserName: "chrome",
131+
},
132+
},
133+
},
134+
plugins: {
135+
/* ... */
136+
"@testplane/global-hook": {
137+
enabled: true,
138+
beforeEach: async ({ browser }: { browser: WdioBrowser }) => {
139+
await browser.url("https://our-site.com");
140+
await browser.restoreState({ path: "./.testplane/state.json" });
141+
},
142+
},
143+
},
144+
} satisfies ConfigInput;
145+
```
146+
105147
## Related Commands {#related}
106148

107149
- [saveState](../saveState)
150+
- [afterAll](../../../config/after-all)
151+
- [beforeAll](../../../config/before-all)

docs/commands/browser/saveState.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ it("test", async ({ browser }) => {
8888
## Related Commands {#related}
8989

9090
- [restoreState](../restoreState)
91+
- [afterAll](../../../config/after-all)
92+
- [beforeAll](../../../config/before-all)

i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/restoreState.mdx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Admonition from "@theme/Admonition";
2+
13
# restoreState
24

35
## Обзор {#overview}
@@ -98,6 +100,50 @@ it("test", async ({ browser }) => {
98100
});
99101
```
100102

103+
Пример реализации аутентификации в тестах с использованием saveState/restoreState и хука beforeAll.
104+
105+
```typescript
106+
import { ConfigInput, WdioBrowser } from "testplane";
107+
import { launchBrowser } from "testplane/unstable";
108+
109+
export default {
110+
gridUrl: "local",
111+
beforeAll: async ({ config }) => {
112+
const b = await launchBrowser(config.browsers["chrome"]!);
113+
114+
await b.url("https://our-site.com");
115+
await b.$("input.login").setValue("[email protected]");
116+
await b.$("input.password").setValue("password123");
117+
118+
await b.saveState({ path: "./.testplane/state.json" });
119+
await b.deleteSession();
120+
},
121+
sets: {
122+
/* ... */
123+
},
124+
browsers: {
125+
chrome: {
126+
headless: false,
127+
desiredCapabilities: {
128+
browserName: "chrome",
129+
},
130+
},
131+
},
132+
plugins: {
133+
/* ... */
134+
"@testplane/global-hook": {
135+
enabled: true,
136+
beforeEach: async ({ browser }: { browser: WdioBrowser }) => {
137+
await browser.url("https://our-site.com");
138+
await browser.restoreState({ path: "./.testplane/state.json" });
139+
},
140+
},
141+
},
142+
} satisfies ConfigInput;
143+
```
144+
101145
## Связанные команды {#related}
102146

103147
- [saveState](../saveState)
148+
- [afterAll](../../../config/after-all)
149+
- [beforeAll](../../../config/before-all)

i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/saveState.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,5 @@ it("test", async ({ browser }) => {
8686
## Связанные команды {#related}
8787

8888
- [restoreState](../restoreState)
89+
- [afterAll](../../../config/after-all)
90+
- [beforeAll](../../../config/before-all)

0 commit comments

Comments
 (0)