Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback: typescript and first impressions #2445

Closed
xenoterracide opened this issue Apr 9, 2020 · 1 comment
Closed

Feedback: typescript and first impressions #2445

xenoterracide opened this issue Apr 9, 2020 · 1 comment
Labels

Comments

@xenoterracide
Copy link

xenoterracide commented Apr 9, 2020

shouldn't this work? or will ava only run precompiled tests

Calebs-MBP:aurelia-propertysource calebcushing$ npx ava --node-arguments="--require ts-node/register --require=tsconfig-paths/register" src/__
tests__

  ✖ Couldn’t find any files to test

Calebs-MBP:aurelia-propertysource calebcushing$ cat src/__tests__/inject.test.ts 
import anyTest, { TestInterface } from 'ava';
import { DI, IContainer, ILogger, LoggerConfiguration } from '@aurelia/kernel';
import { value } from '../decorator';

const test = anyTest as TestInterface<IContainer>;

test.before( ( t ) => {
    const container = DI.createContainer();
    container.register( LoggerConfiguration.create( console ) );
    t.context = container;
} );

test( 'test', ( t ) => {
    class Foo {
        constructor ( @value( 'public.test' ) string: string ) {
            t.context.get( ILogger ).warn( () => '%j', string );
        }
    }

    t.is( t.context.get( Foo ), undefined );
} );
{
    "name": "aurelia-propertysource",
    "version": "0.1.0",
    "description": "Spring Like PropertySource for Aurelia 2",
    "main": "index.js",
    "repository": "https://github.com/xenoterracide/aurelia-propertysource",
    "author": "Caleb Cushing <xenoterracide@gmail.com>",
    "license": "MIT",
    "scripts": {
        "build": "npx tsc --build",
        "test": "npx ava"
    },
    "dependencies": {
        "@aurelia/kernel": "^0.7.0-dev.202004080424",
        "@aurelia/metadata": "^0.7.0-dev.202004080424",
        "jsonpath-plus": "^3.0.0"
    },
    "devDependencies": {
        "@ava/typescript": "^1.1.1",
        "@types/chai": "^4.2.11",
        "@types/node": "^13.11.0",
        "ava": "^3.6.0",
        "chai": "^4.2.0",
        "reflect-metadata": "^0.1.13",
        "ts-node": "^8.8.2",
        "tsconfig-paths": "^3.9.0",
        "typescript": "^3.8.3"
    },
    "ava": {
        "extensions": [
            "ts"
        ],
        "require": [
            "ts-node/register",
            "tsconfig-paths/register"
        ]
    }
}

feels like the documentation needs work

UPDATE
ok, this actually works...

  "ava": {
    "extensions": [
      "ts"
    ],
    "require": [
      "source-map-support/register",
      "ts-node/register",
      "esm"
    ]
  }

except... WAT

Calebs-MBP:aurelia-propertysource calebcushing$ npx ava test/**/*.ts

  
  ✖ Timed out while running tests

  ✖ No tests found in test/inject.spec.ts


Calebs-MBP:aurelia-propertysource calebcushing$ npx ava 

⠙ 2020-04-09T12:49:58.304Z [WRN] ""

  1 test failed

  test

  test/inject.spec.ts:20

   19:                                         
   20:     t.is(t.context.get(Foo), undefined);
   21: });                                     

  Difference:

  - Foo {}
  + undefined
@novemberborn
Copy link
Member

After installing @ava/typescript, setting "typescript": true in the AVA configuration enables TypeScript support. You shouldn't change the extensions.

At the moment, this only works with pre-compiled files (sources & tests). If that's your jam you won't need ts-node/register. This has been working great for my work projects.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants