Code Monkey home page Code Monkey logo

Comments (11)

corbinu avatar corbinu commented on August 21, 2024

@lorenzofox3 Tried it out and I am getting typescript build errors:

✖ 3 problems (0 errors, 3 warnings)

node_modules/zora/dist/declarations/interfaces.d.ts:78:46 - error TS2304: Cannot find name 'AsyncIterable'.

78 export interface TestHarness extends Assert, AsyncIterable<Message<any>>, Counter {
                                                ~~~~~~~~~~~~~

node_modules/zora/dist/declarations/interfaces.d.ts:98:14 - error TS2304: Cannot find name 'AsyncIterable'.

98     (stream: AsyncIterable<Message<any>>): Promise<void>;
                ~~~~~~~~~~~~~

node_modules/zora/dist/declarations/interfaces.d.ts:106:31 - error TS2304: Cannot find name 'AsyncIterable'.

106 export interface Test extends AsyncIterable<Message<any>>, TestResult, Counter {
                                  ~~~~~~~~~~~~~

from zora.

lorenzofox3 avatar lorenzofox3 commented on August 21, 2024

@corbinu I think AsyncIterable are still under esnext for typescript. In your tsconfi file you need to add it as lib

from zora.

corbinu avatar corbinu commented on August 21, 2024

@lorenzofox3 Thanks that helps I had 2018 in there. Do I have to use rollup now on a node project if I want the tests in multiple files?

I really liked the old system where you could export a plan. Any chance of bringing back something where you wrap the tests in a file in a plan and export them up to an index file?

from zora.

lorenzofox3 avatar lorenzofox3 commented on August 21, 2024

@lorenzofox3 Thanks that helps I had 2018 in there. Do I have to use rollup now on a node project if I want the tests in multiple files?

no, just require your test files in some entry point such ./test/index.js, node will concat the files for you.

I really liked the old system where you could export a plan. Any chance of bringing back something where you wrap the tests in a file in a plan and export them up to an index file?

You can still do it (cf previous comment). If you want some more "logic grouping" you can export a sub test:

// ./test/foo.js
module.exports = t => {
    t.test('foo test', t => {
     t.ok(true)
    })

    //etc
}

// ./test/index.js
const {test} = require('zora');

test('./foo.js', require('./foo.js'))

// etc

You can of course use fs or some globby module to automatically load all your test files in the index. Congratulation you have built your first test runner on top of zora :)

from zora.

corbinu avatar corbinu commented on August 21, 2024

@lorenzofox3 Sorry to keep having so many questions. That works however I can't seem to import the type definitions

screen shot 2019-02-03 at 4 38 46 pm

from zora.

lorenzofox3 avatar lorenzofox3 commented on August 21, 2024

TestFunction is not exported, it is used internally

from zora.

corbinu avatar corbinu commented on August 21, 2024

Ok how am I supposed to type these tests then?

from zora.

lorenzofox3 avatar lorenzofox3 commented on August 21, 2024

Ok how am I supposed to type these tests then?

what these tests refer to ? I am not sure to understand your question.

The type system shall know what test function expect even though its argument types are not exported:

compilation error:
type error on zora test method

type inference:
type inference with zora test

If you wish to build on top of zora and manipulate SpecFunction on your code base, indeed it might be easier if zora was exposing this type and at some point it might make sense to expose it as it is a public argument but it should not be blocking:

You can create in your code base your own interface with the same signature and actually it would be probably be safer. Your code shall be responsible to call the zora functions with the appropriate types and typescript will enforce it. If you blindly copy types around you might be in trouble as any changes in zora types will force you to change your api too. Whereas if you use your own types, the only part you would have to change would be the private part of your code which provide valid arguments to zora api.

I try to be conservative in what it is exposed to avoid eventual breaking changes

Maybe you could provide a small repo setup so I can understand your problem.

from zora.

corbinu avatar corbinu commented on August 21, 2024

@lorenzofox3 The problem is since I have my tests in separate files I need to import just the type. I have never seen TypeScript project withhold the types to avoid breakage before. Usually I see that as the way to upgrade a TypeScript dep is to depend on the types to show me the breakage. If this is the not a priority I understand.

from zora.

lorenzofox3 avatar lorenzofox3 commented on August 21, 2024

@corbinu I published a new version with exported types !

from zora.

corbinu avatar corbinu commented on August 21, 2024

Perfect working great!

from zora.

Related Issues (20)

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.