Giter VIP home page Giter VIP logo

supertape's People

Contributors

coderaiser avatar rastaalex avatar tommy-mitchell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

supertape's Issues

Changes to `--require`

In #3, you mentioned that the --require flag could be used for JIT transpilation:

How does the --require flag work? Tape says that it can be used for JIT compilation - does this mean that the supertape CLI could support TypeScript through a required module?

Yes [this could work]

A quick Google search brought me to this article about using tape with TypeScript by requiring ts-node/register/transpile-only (effectively, a module that transpiles TS without type checking). However, trying

$ supertape -r ts-node/register/transpile-only test.ts

Fails with an error message about the .ts extension:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for test.ts

Looking into tape's implementation for --require, it has an import-or-require.js script:

function importOrRequire(file) {
  const ext = extnamePath(file);

  if (ext === '.mjs' || (ext === '.js' && getPackageType.sync(file) === 'module'))
    return import(pathToFileURL(file).href);

  require(file);
};

Compared to Supertape's simple-import.js, which simply uses a dynamic import:

module.exports.simpleImport = (a) => import(a);

I've tested out a simple copy and paste implementation and can successfully run a TypeScript test:

// lib/cli.js

// in function 'cli'
for (const file of files) {
  const resolved = resolvePath(cwd, file);
  promises.push(importOrRequire(resolved));
}
// test.ts
import test from "supertape";

test("test: from ts-node", async t => {
  t.pass("using 'supertape' binary");
  t.end();
});
$ supertape -r ts-node/register/transpile-only test.ts
TAP version 13

1..1
# tests 1
# pass 1

# โœ… ok

What do you think about implementing something like this?

Since v10.0.0 supertape no longer prints ok for passed tests

The problem seems to only happen with --format tap or --format short.

supertape version 9.5.0:

$ supertape --no-check-assertions-count --format tap test/test.js
TAP version 13
# migrate: migration works
ok 1 it did not throw an error
# migrate: migration works the second time
ok 2 it did not throw an error
# orm: select: get works
ok 3 should equal

supertape version 10.0.0 and 10.2.0:

$ supertape --no-check-assertions-count --format tap test/test.js
# migrate: migration works
# migrate: migration works the second time
# orm: select: get works

I expected the output to have lines starting with ok.

Is this useable with TypeScript?

I'm not very familiar with testing in the JS ecosystem, and while setting up a new project I found that I could use Tape to test with:

ts-node node_modules/tape/bin/tape tests/**/*.ts

I like the features of Supertape, but I can't seem to get it to run my tests. I've tried both ts-node and esno/esmo, but I only get a "Done in 0.XXs" output without showing the testing results. Is there something I'm doing wrong, or is this use case not viable?

My test needs startup time before supertape detects tests

(Thank you very much for making supertape, it's the only testing library that matches how my brain works!)

I'm having a problem where supertape is stopping execution before my tests start running. In my test file, I want to do some slow setup (download some files to use in the tests) before the tests execute. But supertape stops it early before it can finish the setup.

From digging into the code, it seems this is because supertape expects one test() to be called in the test file straight away, and then loops every 5 ms until new test()s stop being added. Then it runs all of those tests.

So my test file basically looks like this:

const {test} = require("supertape")
const fetch = require("node-fetch")

const file = await fetch("some url").then(res => res.buffer()) // supertape stops trying to detect tests and stops the tests while this is downloading

test("process: I can process the file", () => {
  t.equal(processFile(file), "expected result")
})

I'd love it if supertape would let me do some setup before I do the tests. I can think of three ways to do this:

  • (a) supertape could wait for my test file to get to at least one test() rather than ending it early
  • (b) OR, supertape could have a setup(async () => { ... }) function that I can put my setup code in, and supertape will wait for setup before detecting tests
  • (c) OR, supertape could have a go() function that I call once I've finished my setup

Do you have any advice on what I can do to make my use case work, or would I have to figure out a different way of doing it?

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.