

@jennifer-shehane How can I solve this issues?
I would like to add I am having similar, inconsistent, behavior with this error. In my scenario, this error only occurs when running all the tests together, and so far has only occurred when the previous test case results in an error that's being addressed in this thread.
Occasionally, when running all tests, I will get the following error
CypressError: Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
The command that returned the promise was:
> cy.visit()
The cy command you invoked inside the promise was:
> cy.viewport()
Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
Cypress will resolve your command with whatever the final Cypress command yields.
The reason this is an error instead of a warning is because Cypress internally queues commands serially whereas Promises execute as soon as they are invoked. Attempting to reconcile this would prevent Cypress from ever resolving.
https://on.cypress.io/returning-promise-and-commands-in-another-command
Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite: 'Register an unregistered th...'
In my before hook for this test case, I have the following code.
before(() => {
cy.viewport('macbook-15');
cy.visit(Routes().dashboardBaseUrl);
cy.get('input[name=email]').type(Accounts().activeIncidentEmail);
cy.get('input[name=password]')
.type(Accounts().activeIncidentPw)
.type('{enter}');
});
I have not overwritten visit nor viewport anywhere in any test case. This never happens when running a single test case by itself, but happens somewhat infrequently when running all tests.
@Dan195 Are you using any custom commands anywhere within your test suite?
Yes I am. None should be overwriting original commands. Am I missing
unintended side effects by utilizing them?
On Tue, Jan 29, 2019 at 11:19 AM Jennifer Shehane notifications@github.com
wrote:
@Dan195 https://github.com/Dan195 Are you using any custom commands
anywhere within your test suite?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/cypress-io/cypress/issues/2979#issuecomment-458627666,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ArXNr1CldqA6SKefm5oUXrcokT6BlmY3ks5vIIK0gaJpZM4ZdssH
.
Could you provide the code within your custom commands?
Edited by @jennifer-shehane at request of @Dan195 (revision history deleted) Removed custom command code due to sensitive data
Yeah, I'm not seeing anything from the examples provided that could be causing the error you provided unfortunately. You'd likely have to simplify the code some to find the smallest reproducible example that causes the error.
Unfortunately we have to close this issue as there is not enough information to reproduce the problem.
Please comment in this issue with a reproducible example and we will reopen the issue. 🙏
I've got the same error.
CypressError: Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
The command that returned the promise was:
> cy.click()
The cy command you invoked inside the promise was:
> cy.wait()
Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
The part getting the error in the test look like:
cy.someCustomCommand(arg);
cy.get('.modal button.btn').click();
In the script in support is:
Cypress.Commands.add('someCustomCommand', function(arg) {
cy.window().should( (win) => {
var someObject = win.someWindowObject;
expect(someObject).to.not.be.undefined;
}).then(() => {
cy.log("Arg: " + arg);
});
}
We see this error sometimes but not always. I hope it's helpful for debugging the issue.
@wataruoguchi There must be some information missing from what is provided above. The error indicates the cy.click() is invoked inside a cy.wait() - can you paste where the cy.wait() is defined?
@jennifer-shehane Oddly, I don't see any cy.wait() in the test code 🤔
I've been seeing the same error. It always happens on the same tests, but only when using the test runner (not headless mode). Also these tests were passing a couple of weeks ago.
Here's an example of the error:

@CJ-Lab7 This error looks to be coming from your own application code. In the error, you can see it is coming from (http://127.0.0.1:32792/js/lims.50c0b27d.js:1) - this is your application's file. Click on the error with DevTools open to see more information about the error.
I just merged some unrelated changes into a new test branch, ran npm i, and the cy.visit() function began throwing this error. I find it odd because I haven't done anything regarding the visit command that is built into cypress. I even looked in the cypress repo to make sure there isn't a wait function inside . Is anyone else having this issue?

Here is the piece of code that is throwing this error:

Unfortunately there is still not enough information to reproduce the problem.
Please comment in this issue with a reproducible example and we will reopen the issue. 🙏
I got the same error on the first type() command
describe('C T', () => {
before(() => {
cy.on('uncaught:exception', (err, runnable) => {
if (err.match(/Uncaught Error: ResizeObserver loop limit exceeded/))
return false
})
})
beforeEach(() => {
cy.server()
cy.fixture('c/all.json').as('fxAllC')
cy.route('**/T**').as('data')
cy.route('GET',
'**/C/T?dateFrom=**',
'@fxAllC').as('fullData')
cy.route('POST', '**/Search').as('search')
cy.login()
cy.visit('/c')
cy.wait('@fullData', { timeout: 20000, })
})
it('Text search', () => {
cy.contains('h1', 'Count')
cy.get('.ct-search .aff input').type('leader')
cy.wait('@search')
cy.get('.aff-item').first().click()
cy.get('.ct-search .aff input').type('11111111111111')
cy.wait('@search')
cy.get('.aff-item').should('not.exist')
cy.get('.ct-search .aff input').type('{enter}')
cy.get('.aff .aff-selected-item').should((items) => {
expect(items).to.have.length(2)
expect(items.eq(1)).to.contain('Leader 1')
expect(items.eq(0)).to.contain('11111111111111')
})
})
})

Also I have commands
Cypress.Commands.add('app', () => {
cy.window().should('have.property', '$app')
return cy.window().its('$app')
})
Cypress.Commands.add('login', () => {
return api.login('User', '123456')
})
I see a similar issue, which occurs randomly when running a certain test:
// all(...) creates it(...) permutations with different viewports and languages
all(
`${testProduct.name} can be found through navigation, sorting and filtering`,
topCategoryPageUrl,
({ viewport, t }) => {
assertBreadcrumbs(2, viewport);
cy.get(`header h1`).should('exist');
// Navigate to sub-category
cy.get(el('CategoryList'))
.find(
`${el('CategoryListItem')} a[href$="${
testProduct.subCategory
}"]:visible`
)
.click();
cy.location('href').should('include', testProduct.subCategory);
cy.get(el('ProductListing', 'category', testProduct.subCategory)).as(
'productList'
);
if (viewport !== 'mobile') {
cy.get('@productList')
.find(el('PanelHeader'))
.contains(t('category', 'products.title'));
}
cy.get('@productList')
.get(el('ProductCard'))
.its('length')
.should('be.gte', 2);
// Sorting
cy.get(el('SortOrderDropdown')).click();
cy.get(
`${el('SortOrderDropdown')} ${el('DropdownOption', 'value', 'price:asc')}`
).click();
assertRouteLoad();
const productPricesSelector = `${el(
'ProductListing',
'category',
testProduct.subCategory
)} ${el('ProductCard')} ${el('PriceLabel')}`;
assertSorted({
selector: productPricesSelector,
parser: val => currency(val).value,
});
cy.get(el('SortOrderDropdown')).click();
cy.get(
`${el('SortOrderDropdown')} ${el(
'DropdownOption',
'value',
'price:desc'
)}`
).click();
assertRouteLoad();
assertSorted({
selector: productPricesSelector,
parser: val => currency(val).value,
comparator: (a, b) => b - a,
});
// ... more test code
}
);
// Some helper functions used in the above test code
export function assertRouteLoad() {
cy.get(el('RouteLoader'), {
timeout: Cypress.config('pageLoadTimeout'),
}).should('exist');
cy.get(el('RouteLoader'), {
timeout: Cypress.config('pageLoadTimeout'),
}).should('not.exist');
}
export function assertSorted({
selector,
timeout = Cypress.config('pageLoadTimeout'),
parser = val => val,
comparator = (a, b) => a - b,
}) {
const startTime = Date.now();
return new Cypress.Promise((resolve, reject) => {
(function poll() {
cy.get(selector).then(elements => {
const values = elements
.toArray()
.map(element => parser(element.innerText));
const sortedValues = values.slice().sort(comparator);
const isSorted = equal(values, sortedValues);
if (isSorted) {
expect(values).to.eql(sortedValues);
resolve(values);
return;
}
if (startTime + timeout < Date.now()) {
expect(values).to.eql(sortedValues);
reject();
return;
}
setTimeout(poll, 500);
});
})();
});
}
// el(...) is a helper function that generates selector strings
This is the error:

As can be seen in the test code, cy.get() is never executed inside a cy.click() promise, which makes the error message kind of odd.
I am also experiencing this issue with cy.type() and cy.clear(). I only saw this issue when upgrading from 3.1.5 to 3.4.1. It happens at random in a specific test suite. It runs without issue headless but fails in Chrome. I installed 3.3.2 to see if that threw the same error message, and it does.
Do you use the cypress-watch-and-reload plugin? Can you reproduce without it?