TEST.AI use in node.js mocha test - node.js

I want insert test.ai abilities to my mocha test I try use test-ai-classifier-client
according to https://github.com/testdotai/classifier-client-node, I tried this code in folder test/rpc-e2e-specs.js
but always get :
TypeError: ClassifierClient is not a constructor
I dont understand the using maybe some one help me how to use TEST.AI in this way or another way
Thank,

Related

Using AfterEach with different file module in NodeJS getting different values

I'm quite new in using Node JS, and I have been working on a test script that take screenshots whenever a test fails. And I'm trying to do this without the use of Jasmine reporter. I tried to use this approach instead Check if test failed in 'afterEach' of Jest without jasmine, however, I'm working with different files I have a file fail_test.spec.js that is used as my main file, and a test_fail1.js as another testscript file. Here is what happening, my test on fail_test.spec.js works fine with the use of AfterEach, just like in the link, it gives me "true" value if the test passed and "false" value when the test fails and it performs screenshot. The problem is the test_fail1.js is also being check by the AfterEach and it constantly gives of a "false" value even if the test passed. I do intend to use AfterEach with the test_fail1.js and on other tests in the future. So my questions are:
Why does the test_fail1.js only gives of constant "false" value?
Is there any work around with this? Because I just only need to know the status of the test in every testscripts within or with other files (ex.fail_test1.js, fail_test2.js, and so on)

How to write Postman tests to compare a response body with an external JSON/CSV file using Newman?

It is well documented how to use an external data file with the Collection Runner in Postman to run multiple iterations. However, what I'd like to do is write tests to compare the response body from a GET request to a JSON/CSV file.
From the research I've done it seems this isn't possible using just Postman. I wonder though if it'd be possible with Newman?
I have no experience with Newman but am curious if this might work. Could you create a Postman collection with an env variable called TestJsonFile and write tests comparing values from that to the response body. Then export said collection and using Newman set the TestJsonFile value to that of a JSON/CSV file (--env-var "TestJsonFile=<path_to_file>") and run the collection with that variable?
This seems plausible to me; maybe I could create a Node project to do it all in one place. I'd just like to ask if anyone has done something similar as it seems like it should be doable.
Any critiques or suggestions would be much appreciated, thank you for reading!

grunt-protractor-runner Option.args mochaOpts

I am having hard time with passing arguments to the grunt-protractor-runner plug-in. I am trying to tag some of my tests and then call that specific test. So, my command for running test's is:
grunt e2e:cert:ed:regression_part_3
But, what I am trying to accomplish is something like this:
grunt protractor --mochaOpts={tags:"myTag"} e2e:cert:ed:regression_part_3
But that doesn't seem to work. Any ideas ?

Using should.js how can I test for an empty object?

user1Stats.should.be.instanceof(Object);
(user1Stats).should.have.keys();
I get the following error:
Error: keys required
at Object.Assertion.keys
The instanceof(Object) works, but I want to make sure there is no data in it.
user1Stats.should.be.an.Object();
user1Stats.should.be.empty();
or, using .and to chain both asserts:
user1Stats.should.be.an.Object().and.be.empty();
P.S. By the way, your code also looks fine.
I check for the variable not being empty by using "should" this way:
user1Stats.should.be.empty();

Is there any way to run an individual test method in groovy?

I'd like to run an individual test method instead of the entire test class in Groovy on the cli - is this possible?
So instead of all the test methods in MyTestClass, I'd like to run just the testArbitrary method in MyTestClass.
Any help appreciated.
In Intellij Idea you could create run configuration, that will start single test method. Command will be copied to output panel and will look like so
com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit3 package.TestClass,testMethod
Like this, you can create your custom JUnitStarter class as described here https://stackoverflow.com/a/9288513/1601606
Natively, there is no such class, but it's pretty simple to create it.

Resources