# nebtest

> NebTest will let you to test your nebulas smart contracts just like you write unit test for any javascript applications.

Latest version **1.0.2** (published 2018-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install nebtest
pnpm add nebtest
yarn add nebtest
bun add nebtest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-07-31 |
| First published | 2018-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 165.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ideas2it |
| Maintainers | alagunagappan, ideas2it-community-admin, kumaralbert, nithin-max |
| Keywords | blockchain, nebulas, nebulas test automation, nebtestkit |

## Links

- npm: https://www.npmjs.com/package/nebtest
- Repository: https://github.com/Ideas2IT/nebtest
- Issues: https://github.com/Ideas2IT/nebtest/issues
- npm.io page: https://npm.io/package/nebtest

## Dependencies (5)

- [chai](https://npm.io/package/chai.md) ^4.1.2
- [mocha](https://npm.io/package/mocha.md) ^5.2.0
- [extend](https://npm.io/package/extend.md) ^3.0.1
- [nebulas](https://npm.io/package/nebulas.md) ^0.5.2
- [winston](https://npm.io/package/winston.md) ^3.0.0

## Recent versions

- 1.0.2 (latest) — 2018-07-31
- 1.0.1 — 2018-07-31
- 1.0.0 — 2018-07-25

## README

# Nebtest

NebTest will let you to test your nebulas smart contracts just like you write unit test for any javascript applications.

# Features

* You can configure for testing in your testnet / mainnet.
* Run test case with multiple test data at a time using json. 
* Will deploy a smart contract before each test case to run your test case in clean state.

# Pre-requisites

* node >= 8.10.3 [(Download the latest node version here)](https://nodejs.org/en/download/)

# Methods

|   Name	|   Parameters	|  Return 	|  Description 	|
|---	|:----:|:----:|---	|
|   createNewAccount	|  - 	|  Account 	|   Creates a new account from wallet	|
|  transferToken 	|  to, token  |  -	|   Send token to the given address from wallet	|
|  deployContract 	|  fileName	|  - 	|  Deploy the contract file |
|  callContract 	|   value, call	|  transaction 	|  Call the specified methods with arguments 	|
|  transact 	|   value, call	|  receipt 	|  Returns the transaction receipt 	|

# Getting Started

1. **Install**  
  npm install --save nebtest  
  npm install --save mocha chai

2. **Include nebtest to your test case**  
  const Nebtest = require('nebtest');

3. **Export variables**  

    Download and follow the instructions to create a web-wallet [https://github.com/nebulasio/web-wallet](https://github.com/nebulasio/web-wallet)  

    Create a wallet  

    <img src="https://raw.githubusercontent.com/Ideas2IT/nebtest/master/screenshot/web-wallet.png" />

    From the wallet info, you will get the wallet details  

    <img src="https://raw.githubusercontent.com/Ideas2IT/nebtest/master/screenshot/wallet-info.png" />

    export ENVIRONMENT='testnet'  
    export SOURCEACCOUNT='wallet private key'  
    export COINBASE='wallet address'

4. **Mock Contract**  
    Place your contract files in test directory
    ```
        test/contracts/contractFile.js
    ```

5. **Test data**  
    Place your test data in test directory
    ```
        test/testCases.json
    ```

6. **Test data - sample format**
    ```
    const testData = [
      {
        name: 'Test Case Description',
        data: [
          {
            name: 'Test data name',
            testInput: {
              ...test inputs
            },
            testExpect: {
              ...test result expect
            }
          }
        ]
      }
    ```
7. **Test Cases**  
    Write your test cases in
    ```
        test/test.js
    ```

8. **Run test**

    Add following command to scripts. The timeout is based on the mining time of the contract you are running. Increase the timeout if you are getting the timeout error.

    ```
    "scripts": {
      ...
      "test": "mocha --timeout 600000"
    }
    ```
    Run the test as,

    ```
      npm run test
    ```

# Example

  Check here for a complete [example](https://github.com/Ideas2IT/nebtest/tree/master/example)

# Resources

  [Steps for creating nebulas web wallet](https://medium.com/nebulasio/creating-a-nas-wallet-9d01b5fa2df6)

  [To claim free nebulas tokens](https://testnet.nebulas.io/claim/https://testnet.nebulas.io/claim/)

---
_Source: https://npm.io/package/nebtest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
