Skip to content

Commit 1ac16fa

Browse files
committed
Use alias to reduce some of the repititon
cypress aliases let you share values between setup and files. See [1] [1] https://docs.cypress.io/app/core-concepts/variables-and-aliases
1 parent d8ebed3 commit 1ac16fa

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

cypress/e2e/spec-wc-pyodide.cy.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe("Running the code with pyodide", () => {
3434
configurable: true,
3535
});
3636
});
37+
cy.get("editor-wc").shadow().children().as("editor");
3738
});
3839

3940
it("runs a simple program", () => {
@@ -152,38 +153,28 @@ describe("Running the code with pyodide", () => {
152153
});
153154

154155
it("runs a program with muiltiple files", () => {
155-
cy.get("editor-wc")
156-
.shadow()
156+
cy.get("@editor")
157157
.findByLabelText('editor text input')
158158
.invoke("text", `from my_number import NUMBER\nprint(NUMBER)\n`);
159159

160-
cy.get("editor-wc")
161-
.shadow()
162-
.findByRole('button', { name: 'Add file' }).click()
160+
cy.get("@editor").findByRole('button', { name: 'Add file' }).click()
163161

164-
cy.get("editor-wc")
165-
.shadow()
166-
.children()
162+
cy.get("@editor")
167163
.findByLabelText(/Name your file/)
168164
.type("my_number.py");
169165

170-
cy.get("editor-wc")
171-
.shadow()
166+
cy.get("@editor")
172167
.findByRole('dialog')
173168
.findByRole('button', { name: 'Add file' }).click()
174169

175-
cy.get("editor-wc")
176-
.shadow()
170+
cy.get("@editor")
177171
.findByLabelText('editor text input')
178172
.invoke("text", `NUMBER = 42\n`);
179173

180-
cy.get("editor-wc")
181-
.shadow()
182-
.findByRole('button', { name: 'Run' }).click()
174+
cy.get("@editor")
175+
.findByRole('button', { name: 'Run' }).click();
183176

184-
cy.get("editor-wc")
185-
.shadow()
186-
.children()
177+
cy.get("@editor")
187178
.find(".pyodiderunner")
188179
.findByLabelText('Text output')
189180
.should("contain", "42");

0 commit comments

Comments
 (0)