Open chbiel opened 4 years ago
Just making sure you're not inadvertently click/pinning snapshots? Doesn't sound like it but just in case.
Just making sure you're not inadvertently click/pinning snapshots? Doesn't sound like it but just in case.
yes. it does not work in both cases. It shows the same behaviour when pinning and hovering a command in the test runner.
Yah, it's possible this could be a bug.
We'll need a reproducible example in order to investigate this, as it's likely highly dependent on the code from he application under test.
Please comment in this issue with a reproducible example or else we will have to close the issue. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.
Ok, I will try to put an example together next week.
When trying to reproduce the issue, I fell over the real issue :) Updated the title and initial report.
Do you need more information or can I further help investigating the issue?
@jennifer-shehane do you need more information? Or can I further help investigate this?
hi @jennifer-shehane, can you remove the "needs information" tag if all informations are provided or point me to what is missing?
I can recreate the issue with the following repo: https://github.com/chbiel/chbiel-cypress-custom-element-react-bug
I'd like to additionally point out that this issue is rather inconvenient during test development as it changes final DOM state even on accidental open log hover.
In our case final state is not reset, but broken due to implementation of connectedCallback
in external component. This might mean test restart is only available workaround.
describe('Custom element and connectedCallback', () => {
it('Renders component as many times as user hovers over log', () => {
cy.log("Hover over me and then hover back to main space.")
cy.visit("https://equinor.github.io/fusion-components/iframe.html?id=general-markdown-editor--default&args=&viewMode=story#/")
})
})
We are also experiencing this error in the time travel. Our issue is that Cypress tries to initiate the custom element without any arguments
We get this error
!
I assume it's because Cypress tries to set innerHTML
or using document.createElement
with the custom element inside of it like this.
<div>
<horizontal-view-tab></horizontal-view-tab>
</div>
or
document.createElement("horizontal-view-tab");
But we only use custom elements through Typescript/Javascript so that we can use initialize the element with parameters.
Here is the relevant code for the custom element
export interface HorizontalViewTabCustomElementArgs {
selectFirstTabAutomatically?: boolean;
selectedTab?: IViewTab;
viewTabs: IViewTab[];
}
export class HorizontalViewTabCustomElement extends HTMLElement {
constructor(private horizontalViewTabArgs: HorizontalViewTabCustomElementArgs) {
super();
const {
selectedTab,
selectFirstTabAutomatically = true,
viewTabs
} = horizontalViewTabArgs;
}
}
Example of usage
const horizontalViewTab = new HorizontalViewTabCustomElement({
viewTabs: []
});
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
This issue has been closed due to inactivity.
When trying to reproduce the problem a found the real issue here :) Previous title: "Test runner "time travel" not working"
The issue is not when using react states in a specific way (as thought earlier).
Current behavior
The issue comes from using custom elements that are added again to the DOM when hovering a command in the test runner and the "connectedCallback" function, that ensures the rendering, is executed again.
Context
We wrap our whole application in custom elements, as we have a distributed frontend architecture that loads applications during runtime and all of that applications are custom elements. That leads to the problem, that the whole application is "reset" to an initial state as the whole application is rendered from scratch when the custom element is loaded in the DOM.
Desired behavior
Also save the custom elements content when creating a DOM snapshot in a way, that does not rerender the custom element when restoring the snapshot.
Test code to reproduce
https://github.com/chbiel/chbiel-cypress-custom-element-react-bug
run
yarn start
thenyarn cypress:open
Previous issue: