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

Selecting by class name in unit tests #244

Open
dan-searle opened this issue Jan 30, 2019 · 2 comments
Open

Selecting by class name in unit tests #244

dan-searle opened this issue Jan 30, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@dan-searle
Copy link
Contributor

dan-searle commented Jan 30, 2019

Because CSS modules are used for x-dash components, the built CSS class names are unpredictable, and so can't (easily) by used as selectors in unit tests, and this is quite limiting.

A couple of possible solutions:

  1. Turn off class renaming in the build used by the unit tests
  2. Support importing of the built css and accessing the generated class names (via classnames?) in the test files

Option 2 would get my vote.

@dan-searle dan-searle added the enhancement New feature or request label Jan 30, 2019
@apaleslimghost
Copy link
Member

i'm 👍 on option two, but i don't know what if anything would need to change about the jest config to get that working.

@dan-searle
Copy link
Contributor Author

With this in x-topic-search/__tests__/x-topic-search.test.js:

import styles from'../dist/TopicSearch.css';

I get this when I run npm test:

  [13:20:05] ✖ File to import not found or unreadable: ~@financial-times/x-follow-button/dist/FollowButton.
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! @financial-times/[email protected] build: `node rollup.js`

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

No branches or pull requests

2 participants