tree: bf55404561149b193d8020d6ea2d197c80357414 [path history] [tgz]
  1. .bazelignore
  2. .bazelrc
  3. BUILD.bazel
  4. decrement.js
  5. index.js
  6. index.spec.js
  7. package.json
  8. README.md
  9. WORKSPACE
  10. yarn.lock
examples/program/README.md

Program example

This example shows how to write a simple Node.js program, with tests.

In this example, we do the opposite of the examples/bazel_managed_deps. Instead, the dependencies are managed explicitly by the user. While we typically prefer to have Bazel manage dependencies, this option could be useful if you vendor the depnedencies into your repository, or use a custom package manager that's not integrated with Bazel.

index.js is the trivial program. You can run it like:

$ bazel run :example 1
Running program
increment 1 is 2

index.spec.js is a test. Run it with:

$ bazel test :test

//:test                                                                  PASSED in 0.2s

Executed 1 out of 1 test: 1 test passes.