Giter VIP home page Giter VIP logo

create-js-workspace-2019-6-13-6-47-30-603's Introduction

Create JS Workspace

Domo

Please go through the demo to create a javascript workspace.

Step1: Create directory

$ mkdir js-workspace

Step2: Step into the directory and initialize a repository. Then copy .gitignore file to that directory

The .gitignore file content can be found at https://github.com/github/gitignore/blob/master/Node.gitignore

$ git init

Step3: Create a node-js workspace by creating a package.json file.

$ npm init

Step4: Add dependencies for your project. Currently, we depend on JEST, which is a unit test framework.

$ npm install jest --save-dev

Step5: create a folder to hold all the test.

$ mkdir __tests__

Step6: Create a unit-test file under the __tests__ folder, and a source code file under the root folder.

$ touch main.js ## if you use PowerShell please type: New-Item main.js -Type File
$ cd __tests__
$ touch main-spec.js

Step7: Write a test first

const add = require('../main');

it ('should add two numbers', () => {
    expect(add(2, 3)).toBe(5);
});

Step8: run the test from the command line:

## Suppose that we are in the root folder
$ node_modules/.bin/jest

Step9: Oh my! the test failed. Let's fix it in main.js file

function add (left, right) {
    return left + right;
}

module.exports = add;

Step10: Run the test again.

Practice

Please do it again all by yourselfs in 10 minutes.

create-js-workspace-2019-6-13-6-47-30-603's People

Contributors

1134923982 avatar linwenjun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.