Skip to content

Commit

Permalink
feat: add unit testing library as dependency (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesudeep authored Jul 6, 2023
1 parent ea68b10 commit e9e4e4b
Show file tree
Hide file tree
Showing 5 changed files with 1,887 additions and 34 deletions.
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,39 +110,51 @@ possible in your explanation and we'll address it as quick as we can.

#### Quickstart Dev Instructions

1. **Install Dependecies.**
1. **Install Dependecies.**

Using yarn, install all dependencies
Using yarn, install all dependencies

```shell
yarn install
```
```shell
yarn install
```

2. **Make changes to the source code**
2. **Make changes to the source code**

3. **Compile your code**
3. **Compile your code**

You need to bundle your code, let's run:
You need to bundle your code, let's run:

```shell
yarn build
```
```shell
yarn build
```

If yarn build fails try using:
If yarn build fails try using:

```shell
bin/build
```
```shell
bin/build
```

4. **Building your code automatically in the background**
4. **Building your code automatically in the background**

Recommended: Webpack can detect changes and build automatically
Recommended: Webpack can detect changes and build automatically

```shell
yarn watch
```
```shell
yarn watch
```

Your compiled code can be found in this repo.
Your compiled code can be found in this repo.

5. Running unit tests

```shell
yarn test
```

or

```shell
bin/test
```

**`./report_table.js`**: This visualization's minified distribution file.

Expand Down
39 changes: 39 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -euo pipefail

GIT_ROOT_DIR=$(git rev-parse --show-toplevel)

# Installs yarn if it is not already installed.
function looker::install_yarn() {
if command -v yarn &> /dev/null; then
npm install -g yarn
fi
}

# Configures the project if the user has not already done so.
function looker::configure() {
looker::install_yarn
pushd "$GIT_ROOT_DIR" &> /dev/null
if [[ ! -d "$GIT_ROOT_DIR/node_modules" ]]; then
yarn
fi
popd &> /dev/null
}

# Runs all the unit tests.
function looker::test() {
pushd "$GIT_ROOT_DIR" &> /dev/null
env NODE_OPTIONS="--openssl-legacy-provider" yarn test
popd &> /dev/null
}

# Entry-point.
function looker::main() {
looker::configure
looker::test
}

looker::main

exit 0
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"css-loader": "^3.6.0",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"jest": "^29.6.1",
"prettier": "^2.8.8",
"style-loader": "^1.2.1",
"url-loader": "^4.1.0",
Expand All @@ -23,6 +24,7 @@
},
"scripts": {
"build": "webpack",
"watch": "webpack --watch --progress"
"watch": "webpack --watch --progress",
"test": "jest"
}
}
9 changes: 9 additions & 0 deletions src/example.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function example() {
return 'hi';
}

describe('example', () => {
test('should say hi', () => {
expect(example()).toBe('hi');
});
});
Loading

0 comments on commit e9e4e4b

Please sign in to comment.