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

Linking master branch for local development #104

Open
mrparkers opened this issue Aug 29, 2016 · 6 comments
Open

Linking master branch for local development #104

mrparkers opened this issue Aug 29, 2016 · 6 comments

Comments

@mrparkers
Copy link
Contributor

Hi all,

I was interesting in taking a look at this library to see how it works and if I was able to help contribute, so I decided to pull it down and link my codebase to use the local version of chai-enzyme.

> git clone git@github.com:producthunt/chai-enzyme.git
> cd chai-enzyme
> npm link
> cd ../my-codebase
> npm link chai-enzyme

After doing this and running my test suite, every single test that uses chai-enzyme assertions fails.

TypeError: Cannot read property 'tagName' of undefined
TypeError: Cannot read property 'className' of undefined
TypeError: Cannot read property 'prop' of undefined

And so on. It looks like wrapper is undefined in assertions/tagName.js, assertions/className.js, assertions/generic.js, etc. After unlinking and pulling the latest version down from npm, these failures go away.

So I guess my question is, am I doing something wrong here? Why do my tests fail when I link to chai-enzyme from a local folder?

@ljharb
Copy link
Member

ljharb commented Aug 29, 2016

You can't simply link anything that has a build process. You'll need to run npm install and npm run build inside the project folder before it can be used.

@mrparkers
Copy link
Contributor Author

Running npm link will automatically run npm prepublish, which includes the install and build process.

mparker:~/Documents/Dev/chai-enzyme (master) $ npm link

> chai-enzyme@0.5.1 prepublish /Users/mparker/Documents/Dev/chai-enzyme
> npm run clean && npm run build


> chai-enzyme@0.5.1 clean /Users/mparker/Documents/Dev/chai-enzyme
> rimraf build


> chai-enzyme@0.5.1 build /Users/mparker/Documents/Dev/chai-enzyme
> babel src --out-dir build

@ljharb
Copy link
Member

ljharb commented Aug 29, 2016

However, that won't install dev dependencies - but sure, if you already have them installed you'll be all set.

Is there anything about your test suite that might be transpiling things in node_modules for you?

@mrparkers
Copy link
Contributor Author

mrparkers commented Aug 29, 2016

My test suite (mocha) uses babel-register. I thought that only transpiled my test files. Does that affect node_modules too?

@ljharb
Copy link
Member

ljharb commented Aug 30, 2016

Yes, babel-register affects everything that uses require.

@mrparkers
Copy link
Contributor Author

Okay, but I still don't understand why this would affect local development. babel-register seems to not be an issue when I'm pulling this down as a devDependency from npm.

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

No branches or pull requests

2 participants