/AlgoCast

About JavaScript Algorithm's and Testing using Jest.

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

JavaScript Algorithm's and Testing using Jest.

Set-up Environment

To begin setting up your environment you need to install Jest.
cd into project and run this line of code:

sudo npm install -g jest

Running test

to open up excercises change into the excercises command

cd excercises

if you run

'jest'

in the command line it will run all the tests available inside every folder.
to run one batch of test

for example the test for excersie "anagram": run the following line

jest anagram/test.js --watch

control C to stop the test runner.


Getting practice using github

Let's Branchout

git fetch to make sure everything is up to date on the main branch and git status to double check everything is up to date.

git fetch
git status

it should show this

On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

now branch out, checkout to a mew_branch where you will be working on a particular algo. Then git remote add upstream to allow you to make changes to your own cloned repo.

git checkout -b new_branch

"...from a forked repo point of view. You have access to pull and push from origin, which will be your fork of the main diaspora repo. To pull in changes from this main repo, you add a remote, "upstream" in your local repo, pointing to this original and pull from it. So "origin" is a clone of your fork repo, from which you push and pull. "Upstream" is a name for the main repo, from where you pull and keep a clone of your fork updated, but you don't have push access to it."
from comment on stackoverflow

git remote add upstream https://github.com/FranciscoAndaur/AlgoCast

Lets try creating a test file.

echo "some test file" > test

echo will create a test file with the string "some test file" saved inside.

cat test

cat will show what's inside the test filem in our case it will print out "some test file" onto the console.

git status
    
On branch test_branch Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: README.md Untracked files: (use "git add ..." to include in what will be committed) test no changes added to commit (use "git add" and/or "git commit -a")

it will show the new test file as red meaning it has some changes ready for us to upload to upload to github.

git add  test

now commit with an descriptive message of what you have done.

git commit -m 'Adding test file to test_branch'
git push -u origin test_branch

Once you push the changes to your repo, the Compare & pull request button will appear in GitHub.


Compare & pull request

Now back in Github.com
We'll see the Compare & Pull request button

image 1

Click it and you'll be taken to this screen:

image 2

This allows the repo's maintainers to review your contribution in our case it's just us, so lets click Create pull request.
From here, we can merge it if it is good

if someone else is reviewing your code, this is where you will do most of the communication.

image 3

Once everything has been reviewed, click Merge Pull Request.

image 4

Then Confirm Pull Request.

image 5

And VOILA!

you've created a test file on a different branch, created a pull request and reviewed it.👏🏼

image 6

the new file should appear on your Main branch now.

image 7

now go back to main branch, fetch and merge your test branch.

git checkout main
git fetch
git merge test_branch
git pull

Companion repo to The Coding Inteview Bootcamp: Algorithms + Data Structures