Skip to content

fix: do cleanup when removeAngularAttributes is enabled #69

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

Closed
wants to merge 3 commits into from

Conversation

tonivj5
Copy link
Contributor

@tonivj5 tonivj5 commented Feb 28, 2020

I have taken your branch to add my changes. I think this approach is cleaner, however, I'm okei with your fix, if you prefer it over this, close this PR 👍

Fixing this issue, removeAngularAttributes can be enabled by default without problems 🎉

Closes #67

@tonivj5 tonivj5 mentioned this pull request Feb 28, 2020
@@ -0,0 +1 @@
declare function afterEach(fn: () => {}, timeout?: number): void;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed to run tests in CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the IDE it shows an error (duplicate identifier)
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to be able to build

@@ -236,3 +239,12 @@ function addAutoImports({ imports, routes }: Pick<RenderComponentOptions<any>, '

return [...imports, ...animations(), ...routing()];
}

if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When process.env.ATL_SKIP_AUTO_CLEANUP is going to be neccessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to be consistent with the rest of the testing libraries

@@ -73,6 +75,7 @@ export async function render<SutType, WrapperType = SutType>(
const idAttribute = fixture.nativeElement.getAttribute('id');
if (idAttribute && idAttribute.startsWith('root')) {
fixture.nativeElement.removeAttribute('id');
cleanup = () => fixture.nativeElement.setAttribute('id', idAttribute);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I restore only the id, because it's the only attribute that Angular need to remove old roots. Should do we restore ng-version too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I wasn't clear, I will follow-up with another PR

@timdeschryver
Copy link
Member

@allcontributors please add @tonivj5 for bug, code

@allcontributors
Copy link
Contributor

@timdeschryver

I've put up a pull request to add @tonivj5! 🎉

@timdeschryver
Copy link
Member

timdeschryver commented Feb 28, 2020

@tonivj5 see #71
Closing this PR in favor of #71

Thanks again for debugging the problem which led to a fix!
I went with the other PR to keep it in line with the other implementations of the testing libraries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants