Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(atomic): exclude lit console warning in cypress assert #5021

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/atomic/cypress/e2e/common-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,18 @@ export function assertConsoleErrorMessage(msg: string) {

export function assertConsoleWarning(warn = true) {
it(`${should(warn)} log a warning to the console`, () => {
cy.get(TestFixture.consoleAliases.warn).should(
warn ? 'be.called' : 'not.be.called'
);
cy.get(TestFixture.consoleAliases.warn).should((spy) => {
const calls = spy.getCalls();
const filteredCalls = calls.filter(
(call) => !call.args[0].includes('Lit is in dev mode.')
);

if (warn) {
expect(filteredCalls).to.have.length.greaterThan(0);
} else {
expect(filteredCalls).to.have.lengthOf(0);
}
});
});
}

Expand Down
5 changes: 3 additions & 2 deletions packages/atomic/cypress/e2e/search-interface.cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {getSampleSearchEngineConfiguration} from '@coveo/headless';
import {TestFixture} from '../fixtures/test-fixture';
import {
assertConsoleErrorMessage,
assertConsoleWarning,
assertConsoleWarningMessage,
} from './common-assertions';
import {addQuerySummary} from './query-summary-actions';
Expand Down Expand Up @@ -171,7 +172,7 @@ describe('Search Interface Component', () => {
);

it('should not log any warning', () => {
cy.get(TestFixture.consoleAliases.warn).should('not.be.called');
assertConsoleWarning(false);
});

it("should update the interface's query pipeline and search hub to match the token", () => {
Expand All @@ -197,7 +198,7 @@ describe('Search Interface Component', () => {
);

it('should not log any warning', () => {
cy.get(TestFixture.consoleAliases.warn).should('not.be.called');
assertConsoleWarning(false);
});
});

Expand Down
Loading