Frontend web application for the Noroff Agency API. Deployed site: agency.noroff.dev
Here's a list of additional documentation available for this project:
For more details, see the documentation directory.
Ensure you have Node.js installed on your system.
Clone the repo:
gh repo clone NoroffFEU/agency.noroff.dev
Install dependencies:
npm i
Do not use live-server or any other server, as this will not work. The project is configured to run with Vite. Run the project with the following command.
npm run dev
This will start a local server on port 5173. You can access the page by going to http://127.0.0.1:5173/.
To build the project, run the following command:
npm run build
This will create a dist
folder in the root of the project, which contains the compiled project.
You can preview the build by running the following command:
npm run build-preview
This is useful to see how the project will look when deployed and to test the build. This is recommended before pushing to the repository, as the build will be tested when creating a PR.
When adding a new page, you must add the page to the vite.config.js
file. This is done by adding the new page to the rollupOptions.input
array. This is to ensure that the page is compiled and added to the build.
Jest is used for unit testing. To run the tests, run the following command:
npm run test-unit
The VSCode extension Jest is recommended for running the tests in the editor. The pre-release version is recommended, as it has better support for Jest. You can enable the pre-release version by installing the normal version, going to the extension settings and enabling the Switch to Pre-Release Version
option.
If you want to run a specific test, you can use the -t
flag. For example, if you want to run the test
in the src/js/utils.test.js
file, you can run the following command:
npm run test-unit -- -t path/to/file.test.js
To run the tests in watch mode, add the --watch
flag and run the following command. This will run the tests in watch mode, which means that the tests will be re-run when a file is changed.
npm run test-unit -- -t --watch path/to/file.test.js
Start by making sure you are working with the most current version of the project:
Switch to Main Branch: First, switch to the main
branch (if you're not there already). This ensures you're updating the right branch.
git checkout main
Pull Latest Changes: Then, pull the latest changes from the main repository. This step updates your local main branch.
git pull
After updating the main branch, create a new branch for your work. Name your branch descriptively, such as feature/new-listing-page
for a new feature or fix/login-issue
for a bug fix.
git checkout -b feature/new-listing-page
Now, it's time to make your changes. Remember to:
Once you start making changes, it's good practice to commit often and keep commits small. This approach helps in maintaining a clear history of changes, making it easier to track and understand each modification. Small, frequent commits are also easier to manage in terms of resolving potential conflicts and reviewing changes.
After you have made a series of commits, push your branch to the remote repository:
git add .
git commit -m "Add new listing page"
git push origin feature/new-listing-page
Remember, regular commits not only help your team members to understand the changes but also assist you in managing your own workflow more effectively.
When your branch is ready:
Visit the GitHub repository. Click on 'Pull Requests' and select 'New Pull Request'. Choose your branch and compare it to the main branch. Fill out the PR template, detailing your changes. Submit your pull request.
If there are any merge conflicts:
git checkout main
git pull
git checkout feature/new-listing-page
git merge main
# Resolve merge conflicts in your editor
git commit -m "Resolve merge conflicts"
git push
Useful video on solving merge conflicts in VS Code
Your PR will be reviewed by a QA team member. If there are any issues, you will be notified and you can make the necessary changes. Once the PR is approved, it will be merged into the main branch.
When you create a pull request towards the main branch, our GitHub Actions test suite automatically runs several checks on your code. These include linting, unit testing, and building the project. It's crucial for your contributions to pass these checks for the following reasons:
Keep an eye on these checks once you submit your pull request. If any checks fail, review the details and make necessary adjustments to your code.
Vanilla js stack
Bootstrap NPM package
jest NPM package Cypress NPM package
dotenv NPM package JSdoc NPM package prettier NPM package eslint NPM package SASS NPM package Vite (for dev server work) NPM package lint-staged NPM package husky NPM package