Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
SandeepNS12
@SandeepNS12
@Zalezale karma is just a task runner which runs your test cases
Joe Pea
@trusktr
Yep, and you can install karma-jasmine, for example, to get the describe/it APIs, but you don't necessarily have to install Jasmine specifically. 👉 https://jasmine.github.io
Zalezale
@Zalezale
but ,why karma can know api like describle,it if it do not contain the api
Joe Pea
@trusktr
I don't think it does. Maybe you have karma-jasmine or karma-chai installed (or something else).
You can run npm ls karma-chai or npm ls karma-jasmine to see if they are installed in your project.
Maybe you followed some tutorial, or maybe some default steps you followed automatically add karma-jasmine?
Zalezale
@Zalezale
yes ,you are right bro
I find the karma-chai at package.json
in fact i just want to find the doc intro the api like it ,describle, thanks
thank you very much
Joe Pea
@trusktr
no prob. In that case https://www.chaijs.com should help out.
kumaraswamyarun
@kumaraswamyarun
I was using jest for testing react components, but jest would not render c3 js or svg elements since it uses jsdom and jsdom is basic only, so I am switching to Karma, since it would run in browser although I am planning to run it in headless browser like phantom js, I think the charts will render using karma, am I correct in this?
kumaraswamyarun
@kumaraswamyarun
yes its working, since using chrome
Joe Pea
@trusktr
@kumaraswamyarun Yep! Hence why I use Karma too (I use karma-electron so that I have both Node.js and Chrome APIs available for tests)
meenanarendra
@meenanarendra
Hi All
How are you doing
I am looking for a solution to unit test javascript of a ASP .NET MVC website. I used Karma, Jasmine and RequireJs but getting error while running test cases
Is their any other way by which we can test this?
Joe Pea
@trusktr
Jest is an alternative to Karma.
electrofLy
@electrofLy
Hey! Do you guys have an idea why would karma connect multiple times to a browser, and just keep making a new connection and disconnecting the previous connection?
electrofLy
@electrofLy
@electrofLy It was because of having window.location.replace code execution in a karma test :P
Joe Pea
@trusktr
Ah
JamesDepret
@JamesDepret
Hi, I have a day pipe which translates the dates to daynames in user specific languages, but i don't know how to mock the service call
PIPE-FILE:
      //function...
      case 0:
        //calling the service here should return 'Sunday' in the appropiate language (this works)
       //I want to build a mock in my test for this: this.lang["core.shared.pipes.weekdays.sunday"]
        return this.lang["core.shared.pipes.weekdays.sunday"];

    }
  }

  get lang() : string {
    return this.language.lang;
  } 
  constructor(private language: AppLanguageService) {}
To test this i thought i had to do following, but this doesn't work:
TEST FILE FOR PIPE:
let mockLanguageService;

    beforeEach(() => {
        mockLanguageService = jasmine.createSpyObj(['lang'])

        TestBed.configureTestingModule({
            imports: [],
            declarations: [],
            providers: [
              {provide: AppLanguageService, useValue: mockLanguageService},
            ]
        });

        // this is wrong, how do I do this correctly?:
        mockLanguageService.lang.and.returnValue({
            ['core.shared.pipes.weekdays.monday']:    "monday",
            ['core.shared.pipes.weekdays.tuesday']:   "tuesday",
            // ...
        });
    })
JamesDepret
@JamesDepret
Nevermind I found it
TEST FILE:
mockLanguageService.lang = ({
            ['core.shared.pipes.weekdays.monday']:    "monday",
            ['core.shared.pipes.weekdays.tuesday']:   "tuesday",
            //...
        });
Alexander Reitzel
@FunTimeCoding
I'm trying to set up a sample project that lets me write modular JS code (either ES6 import/export or requirejs) with a test framework (possibly Jasmine), for websites, and using ChromeHeadless so I can run the same tests on CI.
It's a bit discouraging how much effort that seems to be. Maybe it's even too much effort.
I'd appreciate some advice, pointers, or confirmation that what I'm doing is not very feasible without extensive hacks, or even working examples that I haven't yet tried myself.
It would be really nice to be able to write unit-tested and code coverage measured JS code for websites, without much more overhead.
Cody Mikol
@codymikol
Why is it a lot of effort?
Alexander Reitzel
@FunTimeCoding
I find there are many tools which have been used over the years, and a lot of examples and documentation, and some libraries and frameworks fit together, but some things are just possible with this combination and some with that. It's a large amount of moving parts to consider.
Cody Mikol
@codymikol
If you find it overwhelming, I’d suggest cloning a nodejs starter repository
Rather than try to understand the whole thing see how each piece works independent of the other
Alexander Reitzel
@FunTimeCoding
I had jasmine running in a nodejs environment before. Sort of.
I got confused when trying to use the same template project for both browser based and nodejs based projects
https://github.com/FunTimeCoding/java-script-skeleton/blob/develop/Gruntfile.js this one has most of the things I tried working with the browser part
namely: there is modular code that runs through browserify and gets included, and the code in my main class is being executed
but what doesn't work this way is the jasmine and requirejs are setup
Mahadevan
@karthic2914
Hi All
this is the first time I am joining this room
Cody Mikol
@codymikol
Welcome 👽
Mahadevan
@karthic2914

I have question in stack overflow for karma this is the first time iam using jasmine and karma

can some one please help me I am struggling lot

https://stackoverflow.com/questions/59704920/issue-in-karma-coverage-html-coverage-report-is-empy

Please help me
Mahadevan
@karthic2914
?
Aaron Gray
@AaronNGray
Anyone know how to use karma-fixture with TypeScript and TypeScript Unit Tests ? I think I have all the development files in place but 'fixture' does not seem to be visible like it is in plain JavaScript. The TypeScript compiler is compiling it fine and not complaining. I have tried using @types/karma-fixture but that does not seem to help.
Aaron Gray
@AaronNGray
OKay seem to have solved that !
Peter Sulatycke
@psulat
Does karma support CommonJs out of the box or must you bundle the code first (eg webpack)? I see there is an old karma-commonjs npm project. Are people still using that? I wish the karma document mentioned something about CommonJs. Thanks
mihneagafton
@mihneagafton
Hello everyone! if i have a test, so inside a "describe" element, i get some data trough require, how do i access given data inside each of my "it" statements without calling the endpoint multiple times?
through*
takinaga-dev
@takinaga-dev
Hi, I would like to use latest karama npm package without vulnerability. When is latest package published?