GithubHelp home page GithubHelp logo

izelnakri / qunitx-cli Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 613 KB

CI browser runner for qunitx test framework

License: MIT License

JavaScript 98.20% Dockerfile 0.24% Handlebars 0.12% TypeScript 0.84% HTML 0.38% Nix 0.23%

qunitx-cli's Introduction

QUnitX CLI

CI browser runner for qunitx

QunitX terminal output

Default test output is TAP (Test-Anything-Protocol) thus you can use any tap reporter of your choice to display test output in anyway you like. Example:

# using it with tap-difflet TAP reporter:
qunitx tests/attachments tests/user | npx tap-difflet

Installation:

npm install -g qunitx-cli

qunitx

In order to use qunitx to execute existing qunit tests please change:

import { module, test } from 'qunit';

// to:
import { module, test } from 'qunitx';

Example:

// in some-test.js: (typescript is also supported for --browser mode and node.js with --loader flag)
import { module, test } from 'qunitx';
import $ from 'jquery';

module('Basic sanity check', function (hooks) {
  test('it works', function (assert) {
    assert.equal(true, true);
  });

  module('More advanced cases', function (hooks) {
    test('deepEqual works', function (assert) {
      assert.deepEqual({ username: 'izelnakri' }, { username: 'izelnakri' });
    });
    test('can import ES & npm modules', function (assert) {
      assert.ok(Object.keys($));
    });
  });
});
# you can run the test in node with ES modules package.json{ "type": "module" }
$ node --test some-test.js

# Suggested mode: if you want to run it in CI/google chrome:

$ qunitx some-test.js

# with browser output enabled:

$ qunitx some-test.js --debug

# TypeScript also works, make sure on node.js mode, tsconfig.json exists with compilerOptions.module & compilerOptions.moduleResolution set to "NodeNext":

$ node --loader=ts-node/esm/transpile-only --test some-test.ts

$ qunitx some-test.ts --debug

Code coverage

Since QUnitX proxies to default node.js test runner in when executed with node, you can use any code coverage tool you like. When running the tests in qunit(the browser mode) code coverage support is limited.

c8 node test/attachments test/user

You can browse c8 documentation for all configuration options.

Implementing code coverage for the browser mode is currently not possible because we use esbuild --bundle feature to create a JS bundles for testing in the browser, this could be instrumented with puppeteer-to-istanbul however instrumentation includes transpiled npm imports of qunitx and other potential npm imports developer includes in the code, this cannot be filtered since potential filtering can only occur after the esbuild bundling. When chrome browser and puppeteer fully supports ES asset maps we can remove esbuild from the browser mode, run everything in deno and make instrumentation for code coverage possible with the default v8 instrumentation.

Esbuild plugin interface is an ongoing development, we might be able to figure out a way to generate this instrumentation with esbuild in the future, which could allow code coverage for --browser mode.

qunitx-cli's People

Contributors

izelnakri avatar dependabot[bot] avatar

Stargazers

Sony AK avatar  avatar Ilya Radchenko avatar

Watchers

 avatar  avatar

qunitx-cli's Issues

Better error handling?

As previously reported here: izelnakri/qunitx#74
and following the instructions from the qunitx repo,

I'm running in to this issue:

❯ node_modules/.bin/qunitx 
node_modules/.bin/qunitx: 16: exec: TS_NODE_COMPILER_OPTIONS={"module":"ES2020"}: not found

Hoping an actionable error message could be added.

❯ node --version
v20.4.0

I created my project via:

pnpm add qunitx-cli # automatically creates a package.json if one doesn't exist
volta pin node@20 # since node 20 is required

my whole project
❯ pnpm add qunitx-cli
Packages: +159
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /home/nvp/.local/share/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 181, reused 159, downloaded 0, added 159, done

dependencies:
+ qunitx-cli 0.0.3

Done in 1.9s

~/Development/tmp/test-qunitx 
❯ la
Permissions Size User Date Modified Name
drwxrwxr-x     - nvp  16 Jul 17:51  node_modules
.rw-rw-r--    51 nvp  16 Jul 17:51  package.json
.rw-rw-r--   45k nvp  16 Jul 17:51  pnpm-lock.yaml

~/Development/tmp/test-qunitx 
❯ volta pin node@20
success: pinned [email protected] (with [email protected]) in package.json

~/Development/tmp/test-qunitx 
❯ volta pin pnpm
success: pinned [email protected] in package.json

~/Development/tmp/test-qunitx 
❯ la
Permissions Size User Date Modified Name
drwxrwxr-x     - nvp  16 Jul 17:51  node_modules
.rw-rw-r--   105 nvp  16 Jul 17:52  package.json
.rw-rw-r--   45k nvp  16 Jul 17:51  pnpm-lock.yaml

~/Development/tmp/test-qunitx 
❯ node_modules/.bin/qunitx 
node_modules/.bin/qunitx: 16: exec: TS_NODE_COMPILER_OPTIONS={"module":"ES2020"}: not found

~/Development/tmp/test-qunitx 
❯ cat package.json 
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: package.json
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │     "dependencies": {
   3   │         "qunitx-cli": "^0.0.3"
   4   │     },
   5   │     "volta": {
   6   │         "node": "20.4.0",
   7   │         "pnpm": "8.6.7"
   8   │     }
   9   │ }
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

~/Development/tmp/test-qunitx 
❯ touch some-file.js

~/Development/tmp/test-qunitx 
❯ ./node_modules/.bin/qunitx some-file.js 
./node_modules/.bin/qunitx: 16: exec: TS_NODE_COMPILER_OPTIONS={"module":"ES2020"}: not found

~/Development/tmp/test-qunitx 
❯ nvim

~/Development/tmp/test-qunitx took 9s 
❯ pnpm i
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 321ms

~/Development/tmp/test-qunitx 
❯ ./node_modules/.bin/qunitx some-file.js 
./node_modules/.bin/qunitx: 16: exec: TS_NODE_COMPILER_OPTIONS={"module":"ES2020"}: not found

~/Development/tmp/test-qunitx 
❯ cat package.json 
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: package.json
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │   "type": "module",
   3   │     "dependencies": {
   4   │         "qunitx-cli": "^0.0.3"
   5   │     },
   6   │     "volta": {
   7   │         "node": "20.4.0",
   8   │         "pnpm": "8.6.7"
   9   │     }
  10   │ }
───

I noticed that qunitx doesn't have any peerDependencies, and I see loose references to ts-node, so.. idk what I'm doing wrong 🙃
(I could make assumptions and randomly install things, but the package.json's don't hint at anything, so, that's why I make an issue here, too)

any guidance is much appreciated.

does qunitx-cli require qunitx, qunit, and/or ts-node? I don't see these declared as deps or peerDeps.

Thanks!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.