Comments (4)
The first thing I would try would be to delete the recorded mock file and allow it to be regenerated.
If that doesn't work, I'm not really sure what to tell you. I am wondering if there's an issue with visit(), and if pages are actually being reloaded in this case. That might cause issues.
Another option would be to skip automocker for this case but possibly use it in other tests.
I wish I had a better answer and more time to look into this.
from cypressautomocker.
I'm having exactly the same issue having added this library. Anyone have any ideas of the issue?
from cypressautomocker.
If you comment out the before/after calls, does the same error occur?
Can you provide sample code that demonstrates the issue?
from cypressautomocker.
@scottschafer thanks for coming back to me and creating the plugin.
I've uncommented the before/after calls and the issue does not occur, leading me to believe the problem is with automocker.
For context, I have:
- Installed cypressautomocker as a dependancy
- importted and invoked
installCypressHooks
in the root component of my React app (React v16.3.2) - Imported and invoked
registerAutoMockCommands
in commands.js - Added the before and after blocks to my test files, the simplest example being:
/// <reference types="Cypress" />
describe('Login', () => {
const username = 'testuser';
const password = 'password`
const MOCK_FILENAME = 'groupMock';
before(() => {
cy.automock(MOCK_FILENAME);
});
beforeEach(() => {
cy.visit('/logout');
});
after(() => {
cy.automockEnd();
});
it('Redirects to Dashboard after logging in', () => {
cy.visit('/login');
cy.get('[data-testid=username]').type(username);
cy.get('[data-testid=password').type(password);
cy.contains(/login/i).click();
cy.url().should('contain', '/home');
});
it('Displays error if incorrect username', () => {
cy.visit('/login');
cy.get('[data-testid=username]').type(`${username}s`);
cy.get('[data-testid=password]').type(password);
cy.contains(/login/i).click();
cy.contains('Username is invalid');
cy.url().should('not.contain', '/home');
cy.url().should('contain', '/login');
});
it('Displays error if incorrect password', () => {
cy.visit('/login');
cy.get('[data-testid=username]').type(username);
cy.get('[data-testid=password').type(`${password}s`);
cy.contains(/login/i).click();
cy.contains('Password is incorrect');
cy.url().should('not.contain', '/home');
cy.url().should('contain', '/login');
});
it('Redirects when forgotten password clicked', () => {
cy.visit('/login');
cy.contains(/forgotten password/i).click();
cy.url().should('contain', '/forgotten');
});
});
Any help is greatly appreciated
from cypressautomocker.
Related Issues (15)
- TypeScript HOT 2
- Request and response objects are empty in mock files HOT 7
- addEventListener is missing in XHRRequest mock HOT 3
- Latest code is not deployed to npm HOT 1
- MOCKING ON, but letting this fall through HOT 2
- wait after mocking HOT 1
- Queries not being recorded on POST requests HOT 2
- Stubbed request aborted HOT 1
- Cypress ^3.3.0 Doesn't Recognize `/` at Beginning of Relative Path HOT 4
- Clarification about the web hooks HOT 2
- mocks are not being recording after initial test runs
- What method of testing are you using now? HOT 2
- Last working version Cypress known to work
- AlertMedia AutoMock repo HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypressautomocker.