big-dinner-62817
02/02/2023, 5:18 PMtsconfig.json
(which extends from ./packages/tsconfig
- but that's besides the point).
I want to have a tsconfig.cypress.json
or a way to keep cypress' tsconfig separate. I am inclined to think that this can be configured in the setupNodeEvents
option of cypress.config.ts
- however, I can't find clarity on what I should do. That being said, the RWA example has a tsconfig
in the cypress folder. I tried that and it didn't work - is there something I have to do to point cypress to a specific tsconfig in a specific location?
I'd appreciate some pointers in the right direction.early-book-33004
02/02/2023, 5:35 PMchilly-needle-94710
02/02/2023, 5:39 PMcolossal-hair-89675
02/02/2023, 6:33 PMlate-planet-4481
02/02/2023, 8:55 PMcy.waitForSpinner()
that waits for the loading animation to disappear (if it exists). I would like to overwrite cy.click()
to execute this after every click. I've tried a few ways of doing this, but I don't know the proper syntax to make it work.
This doesn't work:
Cypress.Commands.overwrite('click', (click, ...args) => {
return click(...args).then(() => cy.waitForSpinner())
})
What's the right way to do this?best-lunch-5240
02/02/2023, 9:53 PMcy.createUser()
which implementation looks like this:
Cypress.Commands.add('createUser', (user: User, userNumber: number) => {
user.name = `User ${userNumber}`
cy.request({
method: 'POST',
url: '/createUserEndpoint',
body: user,
headers: {
authorization: 'token'
}
}).then(response => {
return response.body;
});
});
declare global {
namespace Cypress {
interface Chainable {
createUser(user: User, userNumber: number): Chainable<void>;
}
}
}
And in the test to create let's say 3 users one after another I have to do this:
import { userData } from '../../fixtures'
let user: User = JSON.parse(JSON.stringify(userData));
it('test', () => {
cy.createUser(user, 1)
.createUser(user, 2)
.createUser(user, 3);
)};
But is it possible to create a custom command which would chain these commands inside it?
Something like:
Cypress.Commands.add('createUsers', (user: User, usersNumber: number) => {
for (let i = 1; i < usersNumber+1: i++) {
user.name = `User ${userNumber}`
cy.request({
method: 'POST',
url: '/createUserEndpoint',
body: user,
headers: {
authorization: 'token'
}
}).then(response => {
return response.body;
});
}
});
And in the test I would like to have:
import { userData } from '../../fixtures'
let user: User = JSON.parse(JSON.stringify(userData));
it('test', () => {
cy.createUsers(user, 3);
)};
But this code doesn't work the way I would expect it to. Cypress sends a request with the same data of the last iteration so with Body:
{...,"name":"User 3",...}
Is it possible to implement one cystom command which would chain multiple commands on each other for a given number? How to do it?kind-memory-80031
02/02/2023, 10:19 PMgreat-oil-15113
02/02/2023, 10:42 PMquaint-airplane-96634
02/03/2023, 9:29 AMgentle-mechanic-51366
02/03/2023, 9:36 AMbored-baker-20372
02/03/2023, 10:02 AMOops...we found an error preparing this test file:
> cypress/e2e/fetchcookie/fetchCookie.cy.ts
The error was:
Error: Webpack Compilation Error
./cypress/e2e/functions/login.ts
Module not found: Error: Can't resolve '@fixture/userAuto.json' in '/usr/src/app/cypress/e2e/functions'
resolve '@fixture/userAuto.json' in '/usr/src/app/cypress/e2e/functions'
Parsed request is a module
using description file: /usr/src/app/package.json (relative path: ./cypress/e2e/functions)
broad-analyst-94821
02/03/2023, 10:17 AMcypress-promise
to allow for use of async
await
actions to avoid promise hell.
It works locally but fails in beforeAll / before
in the pipeline
How can I avoid promise hell? There are more complex calls that depend on the result of previous calls for the setup between tests.hundreds-library-57018
02/03/2023, 10:32 AMancient-beach-22254
02/03/2023, 12:08 PMcold-author-79999
02/03/2023, 2:55 PMdry-battery-91871
02/03/2023, 3:49 PM"Cross-Origin-Opener-Policy", "same-origin"
"Cross-Origin-Embedder-Policy", "require-corp"
Without the headers, when attempting to run tests in Chrome, the following error appears:
(uncaught exception) ReferenceError:
SharedArrayBuffer is not defined
In Cypress 10 (specifically 10.3.1), we placed these headers in the following file: Cypress/10.3.1/Cypress/resouces/app/packages/server/lib/server-base.js.
This allowed us to run tests in Chrome successfully. However, we have migrated to Cypress 12.4.0, which does not seem to have this file. Where should the headers be placed in Cypress 12.4.0? We added the flag enable-features=SharedArrayBuffer to the launch options in cypress.config.ts, but it either negates or is negated by the other two flags needed to enable visualization in our app (enable-features=Vulkan and enable-unsafe-webgu) depending on which order the flags are set, so we cannot use the flag.loud-leather-28859
02/03/2023, 6:20 PMthousands-kilobyte-34127
02/03/2023, 8:01 PMconst { defineConfig } = require("cypress");
module.exports = defineConfig({
e2e: {
experimentalStudio: true
},
});
But when I run npx cypress open
and get to the e2e tests, the option to add a new test does not appear!
What am I doing wrong?big-secretary-95832
02/03/2023, 8:54 PMprehistoric-stone-17757
02/03/2023, 9:16 PMbillions-king-35651
02/04/2023, 1:17 PMstraight-pencil-91170
02/05/2023, 7:20 AMadamant-printer-77643
02/05/2023, 5:33 PMphp artisan serve --host=127.0.0.1 --port=1234 &
3. Checks the server status using curl: curl -vv http://127.0.0.1:1234
(it returns the correct default page of the api)
4. Runs cypress:
- name: Cypress run
uses: cypress-io/github-action@v5
env:
API_BASE_URL: http://127.0.0.1:1234/
with:
start: npm run dev
wait-on: "http://127.0.0.1:1234/"
5. The cypress command fails on `http://127.0.0.1:1234/ timed out on retry 91 of 3, elapsed 90245ms, limit 90000ms`' in github actions.
Any ideas on how I can debug this further? Thanks!strong-wolf-38676
02/05/2023, 6:47 PMstraight-chef-47891
02/06/2023, 12:28 AMjs
const downloadsFolder = Cypress.config('downloadsFolder');
const path = require('path');
cy.readFile(path.join(downloadsFolder, fileName)).should('have.length.greaterThan', 0);
Not sure if its a chrome thing too.great-oil-15113
02/06/2023, 12:52 AM<html>
<button id="email">Email</button>
<script>
document.querySelector('#email').addEventListener('click', () => {
window.location.href = 'mailto:?subject=XXXXXX&body=YYYYYYlink:%20https:/localhost:12345/id'
})
</script>
</html>
I don't want the email client to open and need to verify the content of the email when click the button. Is there a way to do that?
Thanksmysterious-psychiatrist-29678
02/06/2023, 10:14 AMcy.request({
method: "POST",
url: url,
failOnStatusCode: false,
headers: {
authorization:
"Bearer " + token,
},
}).then((resp) => {
expect(resp.status).to.eq(200);
});
response:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "Upgrade request required",
"reason": "BadRequest",
"code": 400
}
swift-morning-54751
02/06/2023, 3:25 PMform/multipart
but because it has binary data included in a field, the entire request doesn't seem to be presenting well in Cypress.
How do I either parse the request so that I can assert on the multipart
text or work around this somehow?
Using Cypress 12.2.0, working with React and e2e tests. I've tested the flow outside of Cypress and everything works as expected.brief-pencil-55035
02/06/2023, 3:56 PMrhythmic-agency-74865
02/06/2023, 4:57 PM