npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@exercism/javascript-test-runner

v3.2.1

Published

Automated Test runner for exercism solutions in Javascript.

Downloads

12

Readme

Exercism JavaScript Test Runner

javascript-test-runner / deploy javascript-test-runner / main

The Docker image for automatically run tests on JavaScript solutions submitted to exercism.

At this moment, the input path must be relative to the package.json of this repository. jest doesn't like running outside of its tree. This might change in the future.

Installation

Clone this repository and then run:

yarn install

You'll need at least Node LTS for this to work.

yarn build

Usage

If you're developing this, you can run this via yarn or the provided shell script.

  • .sh enabled systems (UNIX, WSL): yarn execute:dev
  • .bat fallback (cmd.exe, Git Bash for Windows): unsupported

You'll want these :dev variants because it will build the required code (it will transpile from TypeScript to JavaScript, which is necessary to run this in Node environments, unlike Deno environments). When on Windows, if you're using Git Bash for Windows or a similar terminal, the .sh files will work, but will open a new window (which closes after execution). The .bat scripts will work in the same terminal. In this case it might be much easier to run bin/run.sh directly, so a new shell won't open.

You can also manually build using yarn or yarn build, and then run the script directly: ./bin/run.sh arg1 arg2 arg3.

Running the Solution's Tests

To run a solution's tests, do the following:

  1. Open terminal in project's root
  2. Run ./bin/run.sh <exercise-slug> <path-to-solution-folder> [<path-to-output-folder>]

For example:

$ ./bin/run.sh two-fer ./test/fixtures/two-fer/pass

Using reporter : **/dist/reporter.js
Using test-root: **/test/fixtures/two-fer/pass/
Using base-root: **/
Using setup-env: **/dist/jest/setup.js

test/fixtures/two-fer/pass/ matches test/fixtures/two-fer/pass/. Not copying anything.
Using test/fixtures/two-fer/pass/.meta/config.json as base configuration
Enabling tests in test/fixtures/two-fer/pass/two-fer.spec.js
Determining test suites to run...
Find the output at:
test/fixtures/two-fer/pass/results.json

Running the Tests of a Remote Solution

Instead of passing in an <exercises-slug> and <path-to-solution-folder>, you can also directly pass in an https://exercism.io url, as long as you have the exercism CLI installed.

You can pass the following type of URLs:

  • Published solutions: /tracks/javascript/exercises/<slug>/<id>
  • Mentor solutions: /mentor/solutions/<id>
  • Your solutions: /my/solutions/<id>
  • Private solutions: /solutions/<id>

For example:

$ ./bin/run.sh https://exercism.io/my/solutions/a7d1b71693fb4298a3a99bd352dd4d74
Exercism remote UUID: a7d1b71693fb4298a3a99bd352dd4d74

Downloaded to
C:\Users\Derk-Jan\Exercism\javascript\clock

...

Determining test suites to run...
Find the output at:
./tmp/clock/a7d1b71693fb4298a3a99bd352dd4d74/clock/results.json

As you can see, it will be copied to a local directory. It's up to you to clean-up this directory.

Running the Solution's Tests in Docker container

This script is provided for testing purposes

To run a solution's test in the Docker container, do the following:

  1. Open terminal in project's root
  2. Run ./run-in-docker.sh <exercise-slug> <relative-path-to-solution-folder>

Maintaining

The package.json needs to be in-sync with the javascript track package.json.

Testing

Running the tests of the test-runner itself can be achieved by using the test script from package.json. The tests delegate to the build output, which is why yarn test first calls yarn build before running jest. The tests take over a minute to run on a decent machine.