brief-kite-35331
02/21/2023, 8:36 AMthankful-wire-37848
02/21/2023, 9:46 AMcy.intercept
routeMatcher works. The docs aren't very specific but it seems that if you use strings there, they will do partial/wildcard/contains matching and not exact string matching. The reason I'm asking is because I'm testing a suggestion feature with two filter fields (first-name and last-name). Changing each field will trigger a call to the suggestion API (actually while typing but cy.type
is fast enough to only trigger it once per field) which I need to intercept. I tried using this code (simplified):
const pathname = `/suggestions`
cy.intercept({
pathname,
query: {
first_name: 'John',
last_name: '',
},
}).as('first-name-search')
cy.intercept({
pathname,
query: {
first_name: 'John',
last_name: 'Doe',
},
}).as('last-name-search')
cy.get('input[name=first_name]').type('John')
cy.wait('@first-name-search')
cy.get('input[name=last_name]').type('Doe')
cy.wait('@last-name-search')
... but then the first-name-search
intercepts both API calls and the empty last_name
query property seems to match twice. So even though there are only 2 API calls, I get three matches in the routes panel.
I can't really use a URL string matcher here as the API library sometimes messes with the query param order. The only thing that got it working for me is to replace the empty string with a very restrictive Regex: /^$/
. Is there no better way than this?witty-pilot-73419
02/21/2023, 10:16 AMcolossal-table-38461
02/21/2023, 11:04 AMcolossal-umbrella-95675
02/21/2023, 1:27 PMbrief-kite-35331
02/21/2023, 3:44 PM{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:cypress/recommended"
],
"parserOptions": {
// Only ESLint 6.2.0 and later support ES2020.
"ecmaVersion": 2020
},
"rules": {
"cypress/no-assigning-return-values": "error",
"cypress/no-unnecessary-waiting": "warn",
"cypress/assertion-before-screenshot": "error",
"cypress/no-force": "warn",
"cypress/no-async-tests": "error",
"node/no-missing-import": "error",
"node/no-unsupported-features/es-syntax": "off",
"no-unused-vars": "off"
}
}
And in the package.json:
"engines": {
"node": ">=8.10.0"
},
But I get this errror for all the imports:
ESLint: "../common/product-detail-actions" is not found.(node/no-missing-import)
On the line like this:
import { ProductDetailPageActions } from '../common/product-detail-actions';
which I know should work.
Can you please advise how to do this properly? What am I missing here?stocky-church-95567
02/21/2023, 5:07 PMfresh-ability-77857
02/21/2023, 5:45 PMimportant-church-36572
02/21/2023, 6:38 PMgray-crayon-29691
02/21/2023, 11:15 PMquaint-airplane-96634
02/22/2023, 7:07 AMjquery-3.6.0.min.js
, Is there any issue with cypress with such xhr calls?victorious-traffic-84253
02/22/2023, 9:54 AMmount
command that wraps my React components with my Redux Provider which works just fine - it's the same as what is explained in this guide https://docs.cypress.io/guides/component-testing/react/examples#Redux.
I have a component which compares it's previous props to it's current props, and so in my component test I need to rerender it from one boolean state to the other; To do this I am making use of the rerender
method like this:
it("temporarily displays a 'saved' state when the 'saving' prop changes from true to false", () => {
const WrappedButton = ({ ...props }) => (
<Button {...props}>Click me</Button>
);
cy.mount(<WrappedButton saving={true} />).then(({ rerender }) => {
cy.get("[data-test='button-loading']").should("exist");
cy.get("[data-test='button-saved']").should("not.exist");
rerender(<WrappedButton saving={false} />);
cy.get("[data-test='button-loading']").should("not.exist");
cy.get("[data-test='button-saved']").should("exist");
});
});
Because my Button
component connects to the Redux store, I'm getting the following error in Cypress when it gets to the rerender…
line of code.
(uncaught exception)Invariant Violation: Could not find "store" in the context of "Connect(Button)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(Button) in connect options.
Does anyone have any ideas how to solve this? If I refactor my Button component so that it doesn't connect to the Redux store everything works as expected, but in this scenario that isn't a viable solution. I would expect any rerendered component to still be wrapped in the Redux Provider.nutritious-honey-65632
02/22/2023, 11:54 AMCypress.Commands.add('getSomeDataById', (dataId, userId) => {
cy.request('GET', '/myEndpoint')
.its('body')
.then((body) => {
body.data.forEach((data) => {
if (data.id === dataId && data.userId === userId) {
cy.wrap(data).as('data');
}
});
});
});
then in the next command I have:
Cypress.Commands.add(
'someOtherCustomCommandForCreation', () => {
cy.get('@data').then((data) => {
// For this data do that
});
},
);
high-holiday-75305
02/22/2023, 2:23 PMyarn build
. Then, in my bug reproduction project, I switched the Cypress version in package.json
from a normal published version to point into the local pre-release build ("cypress": "file:../cypress/cli/build"
). When I run an npm install in the reproduction repo, I get a message saying Warning: You are installing a pre-release build of Cypress.
, which is fair, but then the install fails with Error: Failed downloading the Cypress binary.
. The URL it's saying it tried is https://cdn.cypress.io/beta/binary/12.6.0/darwin-x64/develop-49fdb6bbf1aba86728c219e6b4c04a41299a23d1/cypress.zip, which seems to legitimately be a 404, probably because the hash is of something that isn't a published binary. Does anyone know if it's possible to get this binary installation step to succeed in local development?echoing-tent-95037
02/22/2023, 8:18 PMcypress
directory.melodic-napkin-77320
02/22/2023, 9:42 PMcool-truck-21040
02/23/2023, 12:17 AMnarrow-spoon-96183
02/23/2023, 9:13 AMcy.visit('https://www.google.com/');
cy.get('.LX3sZb .gb_p').contains('Gmail').click({force: true});
This happens in all browsers. Happy to share any other infocold-journalist-13653
02/23/2023, 9:18 AMacoustic-psychiatrist-35111
02/23/2023, 12:23 PMrefined-lamp-49218
02/23/2023, 2:17 PMdamp-appointment-29257
02/23/2023, 3:50 PMgreen-sugar-75539
02/23/2023, 5:02 PMfaint-ocean-92094
02/23/2023, 5:17 PMgorgeous-wolf-24355
02/23/2023, 6:05 PMpowerful-hamburger-23724
02/23/2023, 7:46 PMthousands-hair-55512
02/23/2023, 8:09 PMcy.intercept(`${Cypress.env('API_BASE_PATH')}/**`, ({ headers }) => {
headers['Authorization'] = `Bearer ${Cypress.env('token')}`;
console.log(headers);
}).as('authInterceptor');
agreeable-twilight-32980
02/24/2023, 2:45 AMwitty-gpu-64102
02/24/2023, 9:57 AM