magnificent-lamp-44201
01/23/2023, 9:11 PMdockerfile
that I have, but I got this error:
shell
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
It looks like this is your first time using Cypress: 10.3.1
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux-x64 (Alpine Linux - 3.16.3)
Cypress Version: 10.3.1
My dockerfile
looks like this:
dockerfile
FROM cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
FROM artilleryio/artillery:latest
# Create the folder where our project will be stored
RUN mkdir /my-tests
RUN mkdir /performanceResults
# We make it our work-directory
WORKDIR /my-tests
# Let's copy the essential files that we must use to run our scripts. Right value means the destination
COPY ./package.json .
COPY ./package-lock.json .
COPY ./cypress.config.ts .
COPY ./cypress.env.json .
COPY ./cypress ./cypress
COPY ./performanceTests ./performanceTests
COPY ./.env .
# Install the Cypress dependencies in the work directory
# `RUN npm install` was causing a problem at the moment to execute the dockerfile: 'No version of Cypress is installed in: /root/.cache/Cypress/10.3.1/Cypress'
# To solve that, I copied the `package-lock.json .` and I changed to the following command:
RUN npm ci
# Executable commands the container will use[Exec Form]
ENTRYPOINT ["npx", "cypress", "run"]
# CMD npx dotenv -- artillery run performanceTests/performance.yml
That error is curious because some weeks ago my dockerfile
was working but today no. Is there a way to solve this?calm-gigabyte-78371
01/23/2023, 11:18 PMcolossal-table-38461
01/24/2023, 7:41 AMquaint-dusk-70197
01/24/2023, 8:57 AMcold-author-79999
01/24/2023, 9:18 AMastonishing-secretary-49341
01/24/2023, 9:18 AMmagnificent-baker-97250
01/24/2023, 11:33 AMkind-angle-5131
01/24/2023, 2:56 PMfaint-ocean-92094
01/24/2023, 6:54 PMcy.task("getUserEmail").then((user) => {
user.email = user.email.replace("@ethereal.email", "+TC001" + faker.datatype.float() + "@ethereal.email")
testEmail = user.email
cy.get("#email").type(testEmail)
})
Quick explanation is I create a random new mailbox at project launch, and for each test I need a new account so I use "+TCXXX" and then a randomizer for retries.
I'm declaring testEmail
at the very beggining, outside of the describe block using let testEmail;
which in any other case, it works fine. But in this case, after that task block is executed, testEmail becomes undefined
. What am I doing wrong here? How can I store the value in the variable, and carry it outside of that function?
Btw, this is the simples example, the more complex ones is sql queries, where I need to execute a task for the query, and store a bunch of info from that response in variables, to use on further steps of my test.dry-crayon-91554
01/24/2023, 10:39 PMcold-author-79999
01/25/2023, 3:24 AM:has(td:nth-child(1):contains("${col1}"))
)
.filter(:has(td:nth-child(2):contains("${col2}"))
)
.filter(:has(td:nth-child(3):contains("${col3}"))
)
.filter(:has(td:nth-child(4):contains("${col4}"))
)
.filter(:has(td:nth-child(5):contains("${col5}"))
)
.filter(:has(td:nth-child(6):contains("${col6}"))
)
.filter(:has(td:nth-child(7):contains("DONE"))
);
})
.should("have.length", 1);
it finds two rows with same data instead of onestraight-pencil-91170
01/25/2023, 6:41 AMcolossal-table-38461
01/25/2023, 7:47 AMacceptable-bear-67664
01/25/2023, 10:56 AMcuddly-truck-99344
01/25/2023, 11:36 AMnode --inspect-brk node_modules/cypress/bin/cypress open --dev --inspect-brk
. I am successul to spawn the DevTools in my Chrome for it.
I than slowly step or jump to breakpoints but I get this error
> Error: Cannot find module '\node_modules\scripts\start.js'
End goal is I want to test some nodejs
code that I have added in the cypress.config.ts
such as reading a file with readFileSync
before I export the working config from there. I don't want to rely to do console.log
there since it's very daunting to work with try and guess
rather than inspecting what values you get at anytime during app runtime.
Please help cause no matter how many times and how long I have googled, there is no post, tutorial not even Cypress docs' do have any support in this matter.damp-lawyer-81294
01/25/2023, 12:04 PMbroad-analyst-94821
01/25/2023, 12:30 PMcolossal-kilobyte-99525
01/25/2023, 12:39 PMjs
const path = require('path');
const srcPath = path.resolve(__dirname + '/src/js')
module.exports = {
context: srcPath,
mode: 'production',
watch: false,
entry: {
main: srcPath + '/styleguide/index.js'
},
output: {
filename: 'styleguide-webpack.js'
},
devtool: 'cheap-module-eval-source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
plugins: []
Hope anyone can help faint-ocean-92094
01/25/2023, 4:40 PMrecurse(
() = cy.task('getLastEmail'),
Cypress._.isObject,
{
timeout: 60000,
delay: 5000,
},
)
.its('html')
.then((html) => {
cy.document({ log: false }).invoke({ log: false}, 'write', html)
})
That gets the email, brings it up to the screen, and I can extract anything using regular cypress methods
I assume this part .invoke({ log: false}, 'write', html)
is what needs to change, but I'm not sure how can I do that. Just parsing the HTML and extracting the document but without actually showing the email in the browser, so I can remain in the screen I was at.
Any ideas?acceptable-family-97943
01/25/2023, 4:42 PM.rightclick()
- but to no avail.
Tried dispatching an event on the element itself, didn't trigger it either.
What does work is executing the .rightclick()
twice - but this does seem hacky.wooden-ambulance-41906
01/25/2023, 4:43 PMAn uncaught error was detected outside of a test:
TypeError: The following error originated from your test code, not from Cypress.
> Failed to fetch dynamically imported module: http://localhost:5173/__cypress/src/cypress/support/component.ts
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.
the error is not Consistant and doesn't show up on every run. It also throws on a random test every run. How can I solve this?handsome-cartoon-58565
01/25/2023, 4:58 PMts
cy.fixture('test-image-1.png')
.then((_) => (console.log('image 1?', _), _))
.as('productTestImage1');
cy.fixture('test-image-2.png').as('productTestImage2');
cy.wait(['@productTestImage1', '@productTestImage2']).then((imageFiles) => {
console.log('[[ fixture loaded? ]] /imageFiles:', imageFiles);
forAPI.images = imageFiles;
});
The file structure - which looks fine to me - is as on attached screenshot and yet Cypress throws an error that it's not able to locate the image file and logs don't show up.
What could be the reason?chilly-scientist-69195
01/25/2023, 5:51 PMgifted-greece-75181
01/25/2023, 6:19 PMimport { defineConfig } from 'cypress'
export default defineConfig({
chromeWebSecurity: false,
projectId: 'e1suq1',
fixturesFolder: 'tests/e2e/fixtures',
screenshotsFolder: 'tests/e2e/screenshots',
videosFolder: 'tests/e2e/videos',
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./tests/e2e/plugins/index.js')(on, config)
},
specPattern: 'tests/e2e/specs/**/*.{js,jsx,ts,tsx}',
supportFile: 'tests/e2e/support/index.js',
},
watchForFileChanges: false,
viewportWidth: 1024
})
With Cypress 10.8.0 all my test were passing fine. With upgrade to version 12, I am getting CORS errors - but only in Cypress. (see screenshot)
When I test my app outside Cypress (using it in any browser), everything works just fine.
I tried to change interceptor backend calls to http://0.0.0.0:3000 and it worked, but that raised issues with cookies (as 0.0.0.0 is not localhost).
I am stuck. Is there way to e2e test on this setup?purple-ice-75399
01/25/2023, 6:25 PMbeforeTest(testName) {
console.log(
colors.green(
` ${getUTC()}: Start Time for Test (${testName}) ⏱️ `
)
)
return null
},
That is called in the beforeEach
hook in our cypress/support/e2e.js file - this is also the same structure for our `afterTest`/`afterEach`.
Using console.log in the test:before:run/test:after:run hooks, however, seems to only log it in the browser console, and you can't use tasks in these hooks.
What can I do to make it print to the node console? Thanks in advance!brave-address-8775
01/25/2023, 6:45 PMcy.spy(MyComponent, 'myMethod')
Or do i need a wrapper (with `then`
)?
I can not find any examplesfast-artist-45202
01/25/2023, 7:39 PMNo version of Cypress is installed in: /home/workterminal/.cache/Cypress/9.5.4/Cypress
Please reinstall Cypress by running: cypress install
----------
Cypress executable not found at: /home/workterminal/.cache/Cypress/9.5.4/Cypress/Cypress
----------
A couple coworkers took a stab at it, and this is as far as we could get before I decided to reach out for help here. We got me off the mounted virtual drive, we got NPM and Yarn installed properly after using the linux directory, and then reinstalled Cypress using yarn add cypress@9.5.4
, which completed successfully.
We've tried expanding $PATH to include everywhere where Cypress exists, but it always looks in .cache
. What can I do to toubleshoot further?magnificent-lamp-44201
01/25/2023, 10:26 PMtypescript
describe('Shopping articles in the SWAG Labs store', () => {
let items: object;
beforeEach(() => {
cy.visit('https://www.saucedemo.com/');
cy.loginForm(Cypress.env('valid_user').username, Cypress.env('valid_user').password);
cy.fixture("products").then((product) => {
items = product;
});
});
it('should purchase items from the store', () => {
cy.get('.title').should('have.text', 'Products'); // Checking if I'm in the Products page
// adding the items to the cart
cy.addProductsToCart();
cy.get('#shopping_cart_container').click();
// checking the products I added
cy.get('div[class="inventory_item_name"]')
.then(($item) => {
return (Cypress.$.makeArray($item)).map((el) => el.innerText)
})
.should('deep.equal', items);
cy.get('#checkout').click();
cy.checkoutForm('Eduardo', 'Videgaray', '89000');
cy.get('#finish').click();
cy.get('.complete-header').should('have.text', 'THANK YOU FOR YOUR ORDER')
});
});
I decided to move the logic of checking if the products are already in the cart into a command. I did the following:
typescript
Cypress.Commands.add('validateProductsInCart', () => {
let items: object;
cy.fixture("products").then((product) => {
items = product;
});
cy.get('div[class="inventory_item_name"]').then(($item) => {
return (Cypress.$.makeArray($item)).map((el) => el.innerText)
}).should('deep.equal', items);
cy.get('#checkout').click();
});
but when I used that approach, my items
variable came undefined
. I put a log inside the fixture, just to see if my data was retrieved, and indeed: the data was retrieved.
I put a log outside the fixture, and the items
variable came undefined
. I don't know why. The I tried using a cy.wrap()
inside the fixture, but I got the same behaviour (undefined
).
(cont.)magnificent-cat-57082
01/25/2023, 10:27 PM<iframe name="__privateStripeFrame9846" frameborder="0" allowtransparency="true" scrolling="no" role="presentation" allow="payment *" src="https://js.stripe.com/v3/elements-inner-card-42fc15cfef40ae0d4764d99e5790c6a8.html#fonts[0][family]=Lato&fonts[0][fontSmoothing]=antialiased&fonts[0][src]=local(%22lato%22)%2C+local(%22Lato%22)%2C+url(%22https%3A%2F%2Fassets-sharetribecom.sharetribe.com%2Fwebfonts%2Flato%2FLato-Medium.ttf%22)+format(%22truetype%22)&fonts[0][__resolveFontRelativeTo]=https%3A%2F%2Fapp-staging.solace.health%2Ffindadvocates%2Ftom-marren%2F637051b3-685c-4785-88ac-368cb579b6c6%2Fcheckout&wait=false&mids[guid]=NA&mids[muid]=NA&mids[sid]=NA&style[base][fontStyle]=normal&style[base][fontSmoothing]=antialiased&style[base][fontSize]=16px&style[base][lineHeight]=22px&style[base][color]=%23101010&style[base][::placeholder][color]=%23%235A5A5A&style[base][padding]=30px&rtl=false&componentName=card&keyMode=test&apiKey=pk_test_51LIcjvG7JPMVzIHCacZxdETXWVq1iQXEcLzT3XCgPLoxl0P1jPGfQ82tqQxCrpH9uySUJFdH051pSVmbNHRe7Q5700ebwAoJ7j&referrer=https%3A%2F%2Fapp-staging.solace.health%2Ffindadvocates%2Ftom-marren%2F637051b3-685c-4785-88ac-368cb579b6c6%2Fcheckout&controllerId=__privateStripeController9841" title="Secure card payment input frame" style="border: none !important; margin: 0px !important; padding: 0px !important; width: 1px !important; min-width: 100% !important; overflow: hidden !important; display: block !important; user-select: none !important; transform: translate(0px) !important; color-scheme: light only !important; height: 24px;"></iframe>