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

MNT Fix js tests #1320

Closed

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Jan 12, 2023

Issue silverstripe/silverstripe-admin#1421

This is far from complete, I got as far as getting the admin js to be transformed for jest. There's still a bunch of broken jest tests, most notably AssetAdmin-test.js and AssetAdminRouter-test.js

@@ -0,0 +1,6 @@
{
Copy link
Member Author

Choose a reason for hiding this comment

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

For non-admin modeles it seems that this config needs to be in babel.config.json rather than in package.json/.babelrc - https://babeljs.io/docs/en/configuration#whats-your-use-case

item = ReactTestUtils.renderIntoDocument(
<AssetDropzone {...props} />
);
item = new AssetDropzone();
Copy link
Member Author

Choose a reason for hiding this comment

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

Cannot no longer call constructor() directly on react components, need to use the new keyword

@@ -44,7 +44,8 @@
],
"transform": {
".*": "babel-jest"
}
},
"testEnvironment": "jsdom"
Copy link
Member Author

Choose a reason for hiding this comment

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

This is required for things like 'document' to be globally available

@GuySartorelli
Copy link
Member

Closed in favor of #1330

@GuySartorelli GuySartorelli deleted the pulls/2/jstests branch February 9, 2023 02:18
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