GithubHelp home page GithubHelp logo

Comments (6)

marcoturi avatar marcoturi commented on May 19, 2024

Hi @superkew and thank you for opening an issue. Actually you can't import files in es6 modules syntax using wildcards. If you want to achieve this result you should build a bundle task to run before "npm run test" that bundle all spec files.
Ionic team is working on an a specific task in ionic app script for unit tests and e2e test based on angular cli.

from ionic-boilerplate.

superkew avatar superkew commented on May 19, 2024

It's a pity we can't use the normal karma imports for wildcards, but good to hear that ionic will be creating some tooling for us :)

from ionic-boilerplate.

rkostrzewski avatar rkostrzewski commented on May 19, 2024

@superkew have a look at following gist to achieve such glob support and still use rollup.

There is one problem with such solution tough - you'll have to somehow init test environment (as in current shim). Doing so in every test will throw an error as you can only do so once per test session. I ended up creating singleton for test environment initialization which based on static flag executes following:
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());

from ionic-boilerplate.

marcoturi avatar marcoturi commented on May 19, 2024

just run:
npm run test:watch

And now all your spec file are watched and loaded in karma-shim automatically.

from ionic-boilerplate.

superkew avatar superkew commented on May 19, 2024

Thank you!

from ionic-boilerplate.

mfdeveloper avatar mfdeveloper commented on May 19, 2024

Hey @marcoturi and @superkew . I submitted another approach to do this. The karma-shim.ts is not changed with the watch. I created a file that generate a index.ts with import statements. So, the karma-shim.ts contains only a simple import "../src".

With this, run npm test and the index.ts file will be created on pretest package.json script.

Please, see my PR !1 and check which the better approach to a standard structure :)

from ionic-boilerplate.

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.