Automattic / Automattic/wc-synchrotron

Spike: Look at how to support component-level tests

Open
#72 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
10
Forks
3
PR merge metrics
No merged PRs in 30d

Description

I've spent some time trying to make importing from `wp-calypso` and `gridicons` possible in tests, but to no avail so far. It's a tall order because of the multiple roots in the webpack resolve. This is difficult to make happen with `babel-register` as we're using it now.

The way I see it, here are our options:
1. Run mocha from webpack (difficulties: having mocha iterate through the tree, looking for tests)
2. Add a custom `resolveModuleSource` for `babel-register` that can check multiple source roots.
3. Get us to a single source root by changing all the imports to components.

Also, I've seen this https://github.com/trayio/babel-plugin-webpack-alias which is pretty close to what we need, but it needs to support `resolve.root` for what we want to do to work.

Update: Use shallow rendering
http://slides.com/nordnetacademy/testing-react-apps#/3/8
https://facebook.github.io/react/docs/test-utils.html

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the current babel-register and Mocha setup, then trace how webpack resolves the multiple source roots for wp-calypso and gridicons. Compare the three listed approaches and the shallow-rendering update; the work is done when a concrete approach for component-level tests is selected and its feasibility is established.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript, react, webpack
Domain
frontend, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.