A multi-purpose
- Run
npm install
in your terminal - Then run
npm run build
- Update the
package.json
file "name" field with your own package name. Example@username/package-name
- Create an account with npm if you don't have one already. Also be sure to enable two-factor authentication
- Sign in to your npm account in your terminal with
npm login
- Run
npm publish --access=public
to publish your package
- Install developer dependencies using the following command in your terminal
npm i -D mocha @type/mocha chai @types/chai ts-node
- Create a new file
.mocharc.json
in the root directory with the following contents:{ "extension": ["ts"], "spec": "./**/*.spec.ts", "require": "ts-node/register" }
- Create a
tests
folder - Create an
index.spec.ts
file in thetests
folder - Write unit tests in the
index.spec.ts
file to test the code inindex.ts
- Add a
"test"
property in thepackage.json
file and give it a value of"mocha"
- Run
npm test
in your terminal from the root folder of the project