jeudi 24 août 2017

I can't get FormBuilder from TestBed with FormsModule, ReactiveFormsModule imported

TestBed.configureTestingModule({
    imports: [
        FormsModule,
        ReactiveFormsModule,
    ]
});

TestBed.get(FormBuilder);

What do I need to do? Or I should just use new operator to create one?

Selenium client-sided load test max request per second?

I am using Selenium to perform client-sided testing of a specific browser on an AngularJS web application. I want perform a load test by sending many request from concurrent users. For example, 1k request in a second from x amount of users, 2k request, etc.

There is no formal documentation on this topic. Has anyone done this before? Is there an (expected) maximum amount of request Selenium can perform, I know it would be dependant on hardware. I also know there exist tools such as Jmeter, but those do not run client-side JavaScript.

start browser with specicfic user profile using chromedp

i am using selenium with python and i can do all my testing work using it but i am learning Golang and i want to try to test using it i came across chromedp and i like it but i couldn't figure out how to start google chrome with a specific user profile

can any one help please ?

i am using this example :

package main

import ( "context" "fmt" "io/ioutil" "log" "time"

cdp "http://ift.tt/2jtQ7f4"
cdptypes "http://ift.tt/2w8Hxa9"

)

func main() { var err error

// create context
ctxt, cancel := context.WithCancel(context.Background())
defer cancel()

// create chrome instance
c, err := cdp.New(ctxt, cdp.WithLog(log.Printf))
if err != nil {
    log.Fatal(err)
}

// run task list
var site, res string
err = c.Run(ctxt, googleSearch("site:brank.as", "Easy Money Management", &site, &res))
if err != nil {
    log.Fatal(err)
}

// shutdown chrome
err = c.Shutdown(ctxt)
if err != nil {
    log.Fatal(err)
}

// wait for chrome to finish
err = c.Wait()
if err != nil {
    log.Fatal(err)
}

log.Printf("saved screenshot of #testimonials from search result listing `%s` (%s)", res, site)

}

func googleSearch(q, text string, site, res *string) cdp.Tasks { var buf []byte sel := fmt.Sprintf(//a[text()[contains(., '%s')]], text) return cdp.Tasks{ cdp.Navigate(https://www.google.com), cdp.Sleep(2 * time.Second), cdp.WaitVisible(#hplogo, cdp.ByID), cdp.SendKeys(#lst-ib, q+"\n", cdp.ByID), cdp.WaitVisible(#res, cdp.ByID), cdp.Text(sel, res), cdp.Click(sel), cdp.Sleep(2 * time.Second), cdp.WaitVisible(#footer, cdp.ByQuery), cdp.WaitNotVisible(div.v-middle > div.la-ball-clip-rotate, cdp.ByQuery), cdp.Location(site), cdp.Screenshot(#testimonials, &buf, cdp.ByID), cdp.ActionFunc(func(context.Context, cdptypes.Handler) error { return ioutil.WriteFile("testimonials.png", buf, 0644) }), } }

R: How to tell if any tests failed from result of testthat::test_dir

I have a small testing program that uses testthat

library(testthat)
source("src/MyFile.r")
results <- test_dir("tests", reporter="summary")

So, I am running this via Rscript. The problem is that the exit code is always 0 even when there were test failures. So, I want to call stop if there are any failures. But I can't seem to get the right bit of code to do that. Is there a method or field in results that I should be looking at to determine if there were any errors?

How to unit-test rxjs5?

I've read through this "marble-string" docs, but I juts don't get it.

What I want to test is basically a "protocol". I have a "thing" which is connected to an Observable and which emits data. In my backend code with Rx.NET and C# I have written a helper to test protocols so that my tests look like this:

verifier.Send(new AddMaterialPickCommand(commandId, orderId, materialId: Guid.NewGuid(), quantity: 1))
            .FailWhen<CommandFailedEvent>(e => e.CommandId == commandId)
            .ThenExpect<MaterialPickAddedEvent>(e => e.EntityId == orderId)
            .ThenSend(new DeleteOrderCommand(commandId, orderId))
            .FailWhen<CommandFailedEvent>(e => e.CommandId == commandId)
            .ThenExpect<OrderDeletedEvent>(e => e.EntityId == orderId)
            .ExecuteAndWait(Timeout);

In C# its very easy to connect observables to all things and its also very easy to wait. IMO it is a very readable test code.

With Rxjs5, I didn't find any possibility to wait or do anything similar. So atm I'm failing at just checking that a single thing emitted by my observable is the one expected:

sut.setValue("key1", "key2");
sut.getObservable("key1", "key2")
    .subscribe(value => {
       expect(value).toBe("testValue")  // I want either execute this or fail after a timeout
    });

setValue actually calls next() on a BehaviourSubject.

I'm clueless, any ideas?

Is it possible to make a plugin/ fragment depend on another fragment?

I would like to re-use some test classes, which are living in a dedicated fragment. Require-Bundle wont accept a fragment, Import-Package seems not to consider fragment packages.

How to test asynchronous components

I would like to write some tests for the components that work with data fetching. For example, I need to test this logic:

  1. User click on the button "add image".
  2. A modal window appears and sends a request to get user images. When the request is done - the component shows user images.
  3. User selects one image and click the button "select"
  4. Component should return selected image

To test any part of this logic, I need to w8 after the request is done. How can I do this?

I try to use axios-mock-adapter, moxios, sinon-as-promised, sinon.fakeServer but no one works for me. I can attach my current implementation of this thing here if needed.

P.S. I know that I can break up my test and assay each part. But this is what makes my tests very fragile, just because each time when implementation changes all tests should be rewritten. That's why I start writing tests only for UI but not for implementations