Skip to content

Test running overhaul, switch to Prettier & reformat everything #1407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/Ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,15 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: npm

- name: 📦 Install dependencies
run: npm ci

- name: 🧪 Run all tests
if: ${{ github.event_name == 'push' }}
run: npm run test

- name: 🧪 Run tests for changed files only
if: ${{ github.event_name == 'pull_request' }}
run: npm run test-changed

- name: 💄 Code style
run: npm run style

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ globby([
"!**/test/**/*",
'!**/*.test.js',
'!**/*.manual-test.js',
'!babel.config.js'
'!vitest.config.ts'
])
// create markdown content
.then(pathsToMarkdown)
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/UpdateDirectory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: npm

- name: 📦 Install dependencies
run: npm ci

- name: 🗄️ Create Directory from JS files
run: node .github/workflows/UpdateDirectory.mjs
run: node .github/workflows/UpdateDirectory.js

- name: Configure Github Action
run: |
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname "$0")/_/husky.sh"

npm run style
npm run test-changed
npm run test
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.github
DIRECTORY.md
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"endOfLine": "auto",
"insertPragma": false,
"printWidth": 80,
"printWidth": 120,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
Expand Down
14 changes: 4 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ Be confident that your code works. When was the last time you committed a code c
your app stopped working? Mine was last week. Writing tests for our Algorithms will help us ensure the implementations
are airtight even after multiple fixes and code changes.

We use [Jest](https://jestjs.io/) to run unit tests on our algorithms. It provides a very readable and expressive way to
structure your test code.
We use [Vitest](https://vitest.dev/) to run unit tests on our algorithms. It provides a very readable and expressive
way to structure your test code.

It is advised that the algorithm file (module) does not contain any "live" code but rather just exports the function(s)
needed to execute the algorithm. Your test code can import those function(s), call them with the appropriate parameters
Expand All @@ -122,16 +122,10 @@ If you want to save some time and just run a specific test:
npm test -- koch
```

You can also start Jest in "watch" mode:
You can also start Vitest in "watch" mode:

```bash
npm test -- --watchAll
```

We also prepared a helper script that runs tests only for changed files:

```bash
npm run test-changed
npm test-watch
```

This will run all tests and watch source and test files for changes. When a change is made, the tests will run again.
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# The Algorithms - JavaScript

<!-- Front Matter -->

JavaScript Repository of TheAlgorithms, which implements various algorithms and data structures in JavaScript.

<div align="center">

[![JavaScript Banner][banner]](DIRECTORY.md)
[![JavaScript Banner][banner]](DIRECTORY.md)

[![Checks][checks]][actions]
[![Contributions Welcome][welcome]](CONTRIBUTING.md)
[![standard.js][standard-logo]][standard-js]
[![Discord chat][chat]][discord-server]
[![Checks][checks]][actions]
[![Contributions Welcome][welcome]](CONTRIBUTING.md)
[![standard.js][standard-logo]][standard-js]
[![Discord chat][chat]][discord-server]

</div>

Expand Down Expand Up @@ -39,15 +40,18 @@ many of the algorithms can be found in the [wiki][explanation].
---

<!-- Banner Image -->

[banner]: https://user-images.githubusercontent.com/68542775/167072911-dc31eac8-6885-4a05-9c25-279ecce22a79.png

<!-- Badge Links -->

[standard-logo]: https://img.shields.io/badge/code%20style-standardjs-%23f3df49
[chat]: https://img.shields.io/discord/808045925556682782.svg?logo=discord&colorB=7289DA
[welcome]: https://img.shields.io/static/v1.svg?label=Contributions&message=Welcome&color=0059b3
[checks]: https://img.shields.io/github/actions/workflow/status/TheAlgorithms/JavaScript/Ci.yml?branch=master&label=checks

<!-- External Links -->

[standard-js]: https://standardjs.com/
[discord-server]: https://the-algorithms.com/discord/
[actions]: https://github.com/TheAlgorithms/JavaScript/actions
Expand Down
12 changes: 0 additions & 12 deletions babel.config.cjs

This file was deleted.

Loading