aloof-lifeguard-45424
05/11/2022, 10:44 AMWhy you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
GET /v1/buckets/main/collections/cfr/changeset?_expected=1651612261201 200 532.990 ms - -
GET /v1/buckets/monitor/collections/changes/changeset?collection=whats-new-panel&bucket=main&_expected=0 200 553.418 ms - -
GET /__cypress/tests?p=cypress%5Cintegration%5C1-getting-started%5Ctodo.spec.js 200 1660.547 ms - -
GET /__cypress/tests?p=cypress%5Csupport%5Cindex.js 200 1685.197 ms - -
GET /__cypress/runner/fonts/fa-regular-400.woff2 200 2.331 ms - 13600
GET /v1/buckets/main/collections/whats-new-panel/changeset?_expected=1617030573137 200 545.862 ms - -
GET /__cypress/runner/fonts/mulish-latin-700-normal.woff2 200 1.540 ms - 31176
Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream_base_commons:211:20)
{
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream_base_commons:211:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress-example-kitchensink@0.0.0-development cy:open: `cypress open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cypress-example-kitchensink@0.0.0-development cy:open script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxxxxxxxxxxxxxxxxxxxxx
creamy-minister-50636
05/11/2022, 1:19 PMmagnificent-finland-58048
05/11/2022, 1:32 PMcreamy-minister-50636
05/11/2022, 1:48 PMwitty-room-41457
05/11/2022, 5:33 PMcy.stub
(https://docs.cypress.io/api/commands/stub) or cy.spy
. I have a React app that calls a utility function to get data that I display in a component rendered on a certain page. I wanted to stub that utility function to return something else and ensure that the page renders that data (this is not a component test, but essentially seeding our environment with test data to then click around - we have a ton of tech debt at my startup, so there's unfortunately not an endpoint I can intercept to do this - it's all hard-coded in the frontend).
I'm importing the utility function in my test and then have:
import { classesUtil } from "<path_to_util>";
describe("user can enroll", () => {
it("ensure class is enrollable", () => {
cy.spy(classesUtil, "injectCmsData");
cy.visit("/page");
})
});
When I visit this page, I see in the logs that I'm hitting this util, but when I expect the util to be called, it's not being hit (and the stub shows up in the cypress test runner, but doesn't show any number of calls.
Can you use cy.stub
and cy.spy
on end-to-end tests, or just component tests? This wasn't very clear from the documentationmagnificent-finland-58048
05/11/2022, 6:36 PMwitty-room-41457
05/11/2022, 8:02 PMbrave-apartment-73149
05/11/2022, 8:53 PMred-dentist-71156
05/11/2022, 11:06 PMagreeable-electrician-45843
05/11/2022, 11:36 PMelegant-dog-90839
05/12/2022, 7:10 AMwd-logs-arm
is picked up as well beside the request I wanted to intercept - POST https://portal-dev.workdigital.de/api/v1/deposit
.
This leads to an odd behaivor where the wait('@').then((req))
is returning the wrong request.
Here is how I am registering the interceptor:
js
const url = /(.*)\/deposit(?!(.))/;
cy.intercept(url, (req) => {
req.continue((res) => {
if (forceSuccess) {
res.body.success = true;
} else if (forceFailure) {
res.body.success = false;
} else if (!res.body.success && shouldSucceed) {
expect(
res.body.success,
'It was not possible to change the the widget and it was expected that it would be possible'
).to.be.true;
}
return res;
});
}).as(interceptName);
echoing-painting-40909
05/12/2022, 7:41 AMwd-logs-arm
url. Check if it doesn't end with /deposit
elegant-dog-90839
05/12/2022, 8:19 AMelegant-dog-90839
05/12/2022, 8:20 AMhttps://wd-logs-arm.apm.eu-central-1.aws.cloud.es.io/intake/v2/rum/events"
elegant-dog-90839
05/12/2022, 8:21 AMelegant-dog-90839
05/12/2022, 8:22 AMjs
cy.wait('@deposit').then((req) => {
console.log(req);
depositWidget.submitValidator(req);
cy.isRequestValid(req);
depositWidget.valueOfTheWidgetShouldBe(
req.response.body.data.value
);
});
elegant-dog-90839
05/12/2022, 8:24 AMelegant-dog-90839
05/12/2022, 9:26 AMcreamy-train-56346
05/12/2022, 11:37 AMchannelPage.ts
, later from test file channelPage.spec.ts
):creamy-train-56346
05/12/2022, 11:38 AMcreamy-train-56346
05/12/2022, 11:49 AMelems
array.creamy-train-56346
05/12/2022, 11:50 AMtext
method on each element only one (again the last one) return some string. Subsequent text
attempt fails with following error:creamy-train-56346
05/12/2022, 11:51 AMsparse-insurance-21987
05/12/2022, 1:06 PMgifted-boots-63851
05/12/2022, 1:08 PMgifted-boots-63851
05/12/2022, 1:11 PM@badeball/cypress-cucumber-preprocessor
(upgrade guide: https://github.com/badeball/cypress-cucumber-preprocessor/issues/689)
and also this package for webpack @cypress/webpack-preprocessor
then in your cypress plugin entry point (typically cypress/plugin/index.ts
):
ts
import webpack from '@cypress/webpack-preprocessor'
export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
on('file:preprocessor', webpack({
webpackOptions: require('../webpack.config')(config),
}))
}
where your webpack.config is the following:
js
module.exports = config => ({
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
{
test: /\.feature$/,
use: [
{
loader: '@badeball/cypress-cucumber-preprocessor/webpack',
options: config,
},
],
},
],
},
})
and it should be good
let me know if you dont understand something or still have an issue @sparse-insurance-21987magnificent-finland-58048
05/12/2022, 1:39 PMsparse-insurance-21987
05/12/2022, 2:27 PMhundreds-father-43644
05/12/2022, 4:36 PMdescribe('Edit coupon bad alerts', () => {
const affiliatesUrl = Cypress.env('api_url') + Cypress.env('get_affiliates')
const affiliateCategoriesUrl = Cypress.env('api_url') + Cypress.env('coupon_affiliate_categories')
const getCoupom = Cypress.env('api_url') + "/coupons/385162-2"
beforeEach(() => {
cy.clearCache()
cy.setFirebaseCookies()
cy.intercept('GET', affiliatesUrl, { fixture: 'affiliate/good.response.json' }).as('affiliates')
cy.intercept('GET', affiliateCategoriesUrl, { fixture: 'affiliate-categories/good.response.json' }).as('affiliateCategories')
cy.intercept('GET', getCoupom, { fixture: 'coupon/coupon.json' }).as('coupon');
cy.visit('http://localhost:3000/cupons/385162-2')
cy.wait(['@coupon', '@affiliateCategories', '@affiliates'])
})
it('Should show error alert when edit Coupon failed', () => {
cy.intercept('PATCH', getCoupom, { statusCode: 400 }).as('editCoupon');
cy.get('[data-cy="coupon-id"]').type('TESTE123450192TESTE')
cy.get('[data-cy="coupon-save-button"]').click()
cy.get('[data-cy="snack-alert"]').invoke('text').should('eq', 'Ocorreu um erro inesperado!')
cy.url().should('eq', 'http://localhost:3000/cupons/385162-2')
cy.wait('@editCoupon', { timeout: 50000 })
})
})
rapid-accountant-7361
05/12/2022, 4:56 PM