Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Runs elm-explorations/test suites in Node.js.
When people say “elm-test” they usually refer to either:
npm install --save-dev elm-test
Install elm-explorations/test and create tests/Example.elm
:
npx elm-test init
Run tests in the tests/
folder:
npx elm-test
Run tests in one particular file:
npx elm-test tests/Example.elm
Run tests in files matching a glob:
npx elm-test "src/**/*Tests.elm"
Note: The double quotes are important! Without quotes, your shell might expand the globs for you. With quotes, elm-test expands the globs. This way the watcher can pick up new tests matching the globs, and it will work cross-platform.
Run in watch mode:
npx elm-test --watch
There are 3 places you could put your tests:
In the tests/
folder.
This is the default and requires no extra setup.
In any source directory ("source-directories"
in elm.json
for applications, src/
for packages) as separate files.
A convention is to put test files next to the file it tests with a Tests
suffix. For example, you could have src/LoginForm.elm
and src/LoginFormTests.elm
.
This requires telling elm-test which folders/files to run. Examples:
npx elm-test "src/**/*Tests.elm"
npx elm-test test/frontend/elm
You might also need to configure your editor to understand that the "test-dependencies"
in your elm.json
are available in these files.
In already existing source files.
This allows testing internal functions without exposing them. (Be aware that testing implementation details can sometimes be counter-productive.)
This requires moving everything in "test-dependencies"
in your elm.json
into regular "dependencies"
, so your project still compiles. This also helps your editor. Note that this approach isn’t suitable for packages, since you don’t want your package to unnecessarily depend on elm-explorations/test.
You can mix all three variants if you want:
npx elm-test tests "src/**/*Tests.elm" app
In this example,
"src"
and"app"
need to be in"source-directories"
inelm.json
.
For elm-test to find tests in your files you need to:
Test
.Example:
module LoginForm exposing (alreadyLoggedInTests, tests)
import Test exposing (Test)
tests : Test
tests =
-- ...
alreadyLoggedInTests : Test
alreadyLoggedInTests =
-- ...
Some prefer to expose a single Test
value and group everything using describe. Some prefer to expose several Test
values.
Also check out the elm-explorations/test quick-start guide!
These are the most common commands and flags. Run elm-test --help
for an exhaustive list.
Note: Throughout this section, the npx
prefix is omitted for brevity.
Like elm install
, except elm-test will install to "test-dependencies"
in your elm.json
instead of to "dependencies"
.
elm-test install elm/regex
Runs elm-test install elm-explorations/test
and then creates a tests/Example.elm
example test to get you started.
elm-test init
requires an elm.json
file up the directory tree, so you will need to run elm init
first if you don’t already have one.
After initializing elm-test in your project, try out the example by running elm-test
with no arguments.
elm init
elm-test init
elm-test
Start the runner in watch mode. Your tests will automatically rerun whenever your project changes.
elm-test --watch
Run with a specific fuzzer seed, rather than a randomly generated seed. This allows reproducing a failing fuzz-test. The command needed to reproduce (including the --seed
flag) is printed after each test run. Copy, paste and run it!
elm-test --seed 336948560956134
Define how many times each fuzz-test should run. Defaults to 100
.
elm-test --fuzz 500
Specify which format to use for reporting test results. Valid options are:
console
(default): pretty, human readable formatted output.json
: newline-delimited json with an object for each event.junit
: junit-compatible xml.elm-test --report json
Disable colored console output.
Colors are also disabled when you pipe the output of elm-test
to another program. You can use --color
to force the colors back.
Alternatively, you can set the environment variable FORCE_COLOR
to 0
to disable colors, or to any other value to force them.
See chalk.supportsColor for more information.
If elm
is not in your $PATH
when elm-test runs, or the Elm executable is called something other than elm
, you can use this flag to point to your installation.
elm-test --compiler /path/to/elm
To run a tool installed locally using npm
you can use npx
:
npx elm-test
npx
adds the local node_modules/.bin/
folder to $PATH
when it executes the command passed to it. This means that if you have installed elm
locally, elm-test
will automatically find that local installation.
As mentioned in Installation we recommend installing elm-test locally in every project. This ensures all contributors and CI use the same version, to avoid nasty “works on my computer” issues.
If you want to run your tests on Travis CI, here's a good starter .travis.yml
:
language: elm
elm:
- 0.19.1
Here is an example travis.yml
configuration file for running tests in CI.
0.19.1-revision8 - 2022-06-20
elm-test install-unstable-test-master
master
version of the elm-explorations/test
library in place of the 1.2.2
version in your ELM_HOME
elm-test uninstall-unstable-test-master
This let’s you test the upcoming major version of elm-explorations/test. Big thanks to Martin Janiczek!
elm-test no longer uses elm-json to calculate the set of dependencies needed to run your tests. Instead, we use elm-solve-deps-wasm which basically is a WebAssembly port of the dependency solver in elm-test-rs. Big thanks to Matthieu Pizenberg! Benefits of this change:
elm-test now shows suggestions on misspelled CLI flags.
module MyTest exposing (..)
with the expose-all (..)
and a char literal with a unicode escape, like '\u{000D}'
, in the same file, elm-test now correctly finds all tests to run in that file. A bug with unicode escape parsing previously caused no tests to be found.FAQs
Run elm-test suites.
The npm package elm-test receives a total of 15,347 weekly downloads. As such, elm-test popularity was classified as popular.
We found that elm-test demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.