Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
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.
codymikol
@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.
codymikol
@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
codymikol
@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*