https://github.com/thekashey/package-self
Place yourself in the right place.
https://github.com/thekashey/package-self
npm npm-scripts package testing
Last synced: 10 months ago
JSON representation
Place yourself in the right place.
- Host: GitHub
- URL: https://github.com/thekashey/package-self
- Owner: theKashey
- Created: 2017-12-22T11:45:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-04-19T01:27:04.000Z (about 4 years ago)
- Last Synced: 2024-10-15T05:31:09.756Z (over 1 year ago)
- Topics: npm, npm-scripts, package, testing
- Language: JavaScript
- Size: 8.79 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# package-self
[](https://nodei.co/npm/package-self/)
The common mistake for any library is quite simple, but hard to spot.
> As a library creator you are testing you library __NOT__ as a library.
Usually - one will run tests against /src folder. Usually - no one will test how
final customer will use and consume your library.
This includes:
1. Your package was broken on build
2. Typing, you provided, is wrong
3. Babel magic wont work
4. You forget to write down a new file into your package.json
5. .....
## Solution
```js
npm install package-self
npm run package-self
```
This will install a package as local dependency, next you can use in in your test
##### Before
```js
import myFunction from '../src/index.js'
declare('lets test it!'....)
```
You should not test yourself in as your self.
##### After
```js
import myFunction from 'myLibrary'
declare('lets test it!'....)
```
Now you can test yourself as your final user will use you.
### Hint
Not all tests could and should be run using the `real` bundle code.
But you shall test your public API using the code, you will ship to a customer, not local sources.
### PS
As we test this library.
PPS: Inspired by [React tooling bloppost](https://reactjs.org/blog/2017/12/15/improving-the-repository-infrastructure.html#simulating-package-publishing),
also some code has origins from that article.
# Licence
MIT