So guys, I'm running some tests using brain.js, I got this code from different examples, but when I try to run it, nothing happens, there is no response. I already tried to wait few time to see if it would come up with a response, but seems to be doing nothing..
import brain from 'brain.js'
const net = new brain.recurrent.LSTM();
net.train([
{ input: "my unit-tests failed.", output: "software" },
{ input: "tried the program, but it was buggy.", output: "software" },
{ input: "i need a new power supply.", output: "hardware" },
{ input: "the drive has a 2TB capacity.", output: "hardware" },
{ input: "unit-tests", output: "software" },
{ input: "program", output: "software" },
{ input: "power supply", output: "hardware" },
{ input: "drive", output: "hardware" },
]);
console.log("output = " + net.run("drive"));
I don't think this is a problem related to the code because as I said, I saw like 3 different examples running almost the same code, just changing the data, and it is not working for me. What can be the problem?
Related
I have some sample Mocha codes as below:
function runMochaTestSuite(testSuite) {
describe(testSuite.name, function () {
for (testCase of testSuite.testCases) {
it(testCase.name, function () {
});
}
});
}
const myTestSuites = [
{
name: "Test Suite 1",
testCases: [
{
name: "Test Case 1-1",
},
{
name: "Test Case 1-2",
},
],
},
{
name: "Test Suite 2",
testCases: [
{
name: "Test Case 2-1",
},
{
name: "Test Case 2-2",
},
],
},
];
for (suite of myTestSuites) {
runMochaTestSuite(suite);
}
I run this ok with Mocha version 7.
how can I make use of new parallel option in version 8 to run the test suites like above in parallel?
Much appreciated for your help.
Thank you in advance.
You can't.
The documentation says:
Use the --parallel flag to run tests in a worker pool.
Each test file will be put into a queue and executed as workers become available.
The parallel execution is file based, not single test based.
I'm working on confirmation emails and i need to send an .ics request by mail to ask the customer whether we can deliver at a certain time. As I am testing this, I can't respond from Outlook. When i try my gmail address I can reply perfectly. I'm thinking that maybe my formating is wrong?
I'm using this ics library
Here is the relevant code:
const event = {
start: [
startDate.getFullYear(),
startDate.getMonth() + 1,
startDate.getDate(),
startDate.getHours(),
startDate.getMinutes(),
],
end: [
endDate.getFullYear(),
endDate.getMonth() + 1,
endDate.getDate(),
endDate.getHours(),
endDate.getMinutes(),
],
organizer: {
name: "Test Test",
email: "souf#test.test", //for testing
},
method: "REQUEST",
title: `${deal.title} (${deal.reference})`,
description: deal.summary,
location: addressToString(customer.address),
status: "CONFIRMED",
attendees: [{
name: "Test",
email: "kri#test.test",
rsvp: true,
role: 'REQ-PARTICIPANT',
partstat: 'NEEDS-ACTION',
}],
};
and the output afterwards read out of notepad is:
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:adamgibbons/ics
METHOD:REQUEST
X-PUBLISHED-TTL:PT1H
BEGIN:VEVENT
UID:dadb3c31-25e9-4026-9878-c1001f4e9a39
SUMMARY:Offerte V1 LG / 1 buiten unit & 1 binnen unit (P4660)
DTSTAMP:20201012T135254Z
DTSTART:20201015T070000Z
DTEND:20201015T150000Z
LOCATION:
STATUS:CONFIRMED
ORGANIZER;CN=Test Test:mailto:souf#test.test
ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;CN=Test:mailt
o:kri#test.test
END:VEVENT
END:VCALENDAR
The message must have the VCALENDAR above as the one and only MIME part, not an attachment. The message content type must be "text/calendar"
my Test config file is not able to find the spec file. i already have spec files created. previously i ran those scripts also.. but for more framework update i updated the paths of the files.. that makes spec files error and even i gave the full path also it is not able to find the spec file.
Spec File
var utilityInit,page2//browser2;
page1=new facebook(firstBrowser);
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
await firstBrowser.get(properties.get("url1"));
browser.logger.info("Title of the window is :"+await browser.getTitle());
//screenshots.takesScreenshot("filename");
});
this.When(/^User entered the text in the search box$/,async function(){
firstBrowser.sleep(3000);
await page1.email().sendKeys(testData.Login.CM[0].Username);
browser.sleep(3000);
await page1.password().sendKeys(testData.Login.CM[0].Password);
});
this.Then(/^click on login button$/,async function(){
browser.sleep(3000);
await facebook.submit().click();
});
this.Then(/^User tried to open in new browser instance$/,async function(){
browser2=await openNewBrowser.newBrowserInit(firstBrowser);
utilityInit=new utility(browser2);
utilityInit.ignoreSync(properties.get("url2"));
browser2.manage().window().maximize();
console.log(await utilityInit.title()+" title");
browser2.sleep(5000);
});
this.When(/^User entered the text in the email field$/,async function(){
page2=new facebook(browser2);
console.log(await page2.title()+" browser2");
await page2.search().sendKeys("testing");
browser2.sleep(3000);
page1=new facebook(firstBrowser);
console.log(await page1.title()+" browser1")
await page1.email().sendKeys(testData.Login.CM[0].Username);
screenshots.takeScreenshot("newScreenshot");
firstBrowser.sleep(5000);
})
}
Config file
const log4js = require('log4js');
var fs=require('fs');
global.screenshots = require('protractor-take-screenshots-on-demand');
global.browser2;
var propertiesReader=require('properties-reader');
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome',
metadata: {
browser: {
name: 'chrome',
version: '79'
},
device: 'MacBook Pro 15',
platform: {
name: 'OSX',
version: '10.12.6'
},
disableLog:true,
durationInMS:true,
openReportInBrowser:true
}
},
ignoreUncaughtExceptions:false,
// Spec patterns are relative to this directory.
specs: [
'../Proc/src/test/java/com/proc/features/test.feature'
],
beforeLaunch:function(){
if (fs.existsSync('./logs/ExecutionLog.log')) {
fs.unlink('./logs/ExecutionLog.log')
}
log4js.configure({
appenders: {
out: { type: 'console' },
info:{ type: 'dateFile', filename: '../Reports/logs/info', "pattern":"-dd.log",alwaysIncludePattern:false},
"console" : {
"type": "console",
"category": "console"
},
"file" : {
"category": "test-file-appender",
"type": "file",
"filename": "../Reports/logs/log_file.log",
"maxLogSize": 10240,
// "backups": 3,
// "pattern": "%d{dd/MM hh:mm} %-5p %m"
}
},
categories: {
"info" :{"appenders": ["console"], "level": "info"},
"default" :{"appenders": ["console", "file"], "level": "DEBUG"},
//"file" : {"appenders": ["file"], "level": "DEBUG"}
}
});
},
cucumberOpts: {
require:['../src/test/resources/com.proc.utility/timeOutConfig.js','../src/test/java/com/proc/TestCases/spec.js'],
tags: false,
profile: false,
format:'json:../Reports/jsonResult/results.json',
'no-source': true
},
onPrepare: function () {
const logDefault = log4js.getLogger('default');
const logInfo=log4js.getLogger('info');
screenshots.browserNameJoiner = ' - '; //this is the default
//folder of screenshot
screenshots.screenShotDirectory = '../Screenshots';
global.openNewBrowser=require("../src/test/resources/com.proc.utility/newBrowserinstance.js")
global.testData=require("../TestData/testData.json");
browser.logger = log4js.getLogger('protractorLog4js');
global.firstBrowser=browser;
global.properties=propertiesReader("../TestData/propertyConfig.properties");
browser.waitForAngularEnabled(false);
browser.manage().window().maximize();
global.facebook=require("../src/test/java/com/proc/pages/fbPageObjects.js");
global.utility=require("../src/test/resources/com.proc.utility/testFile.js");
},
plugins: [{
package: '../Proc/node_modules/protractor-multiple-cucumber-html-reporter-plugin',
options:{
// read the options part for more options
automaticallyGenerateReport: true,
removeExistingJsonReportFile: true,
reportPath:"../Reports/HtmlReports",
reportName:"test.html"
},
customData: {
title: 'Run info',
data: [
{label: 'Project', value: 'Framework Setup'},
{label: 'Release', value: '1.2.3'},
{label: 'Cycle', value: 'Test Cycle'}
]
},
}]
};
Log
H:\workspace\Proc\Configuration>protractor testConfig.js
[23:38:00] I/launcher - Running 1 instances of WebDriver
[23:38:00] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:51680/devtools/browser/e9688f83-2047-4535-91ba-bf2100fe6016
0 scenarios
0 steps
0m00.000s
can some one please help me to clear this issue.. this is related to my project framework POC..
To clarify some other comments I have seen being made by others here, you do not have to give the exact file path. You can do
specs: [
'../Proc/src/test/java/com/proc/features/']
This path does not look correct to me ^ are you sure that is the correct path? also you have a javascript project but your file structure is a java structure src/test/java why?
it's a simple thing that makes my framework works..
npm install cucumber#1.3.3 --save-dev
This because of the Spec path
specs: [
'../Proc/src/test/java/com/proc/features/test.feature' //Provide a complete path to your test file along with file extension(.ts)
],
Hope it helps you
I would like to print the status of each cucumber scenario using the afterScenario hook.
I've tried printing out scenario.status (code below) but it prints out "undefined"
afterScenario: (scenario) => {
console.log(scenario.status);
}
When printing out just scenario, I don't see status.
Scenario {
feature:
Feature {
description: undefined,
keyword: 'Feature',
line: 1,
name: 'Sample Test',
tags: [],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
scenarios: [ [Circular] ] },
keyword: 'Scenario',
lines: [ 15, 7 ],
name: 'Getting test status',
tags:
[ Tag { line: 6, name: '#WIP' }],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
line: 15,
description: undefined,
steps:
[ Step {
arguments: [],
line: 4,
name: 'I am on the app',
scenario: [Circular],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
isBackground: true,
keyword: 'Given ',
keywordType: 'precondition' },
Step {
arguments: [],
line: 8,
name: 'I am viewing the splash screen',
scenario: [Circular],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
isBackground: false,
keyword: 'Given ',
keywordType: 'precondition' } ] }
I had a read through https://docs.cucumber.io/cucumber/api/#hooks which suggested (from my understanding) to do scenario.failed, but I still get undefined.
Would anyone be able to tell me how I can get the status of a scenario?
I am using cucumber v3.2.1 and wdio-cucumber-framework v1.0.3.
Answer is simple, you should be console logging "scenario.result.status" instead of scenario.status.
Hope this answer helps you!
Below should work-
(tried with wdio-cucumber)
After(function (scenarioResult) {
const scenario = scenarioResult.scenario;
console.log('SCENARIO EXECUTION COMPLETED:',scenario.name);
});
This is not an answer just a suggestion. I would look into how the report.json is built as that report has all the scenarios and their result.
Another pointer is in your cucumber.js file set the reporting format you want to progress which will output progress to the console.
Take a look at https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#Formats
I've been learning Meteor for about 3 weeks, and am still trying to wrap my head around updating/querying collections. I'm trying to build a Slack clone, and created the following collection with one set of fixture documents:
Conversations.insert({
channel: "#defaultChannel",
createdBy: "coffeemeup",
timestamp: new Date(),
followers: ["username1", "username2"],
entries: [
{
message: "this is a message #1",
postedTime: new Date(),
author: "coffeemeup"
}]
});
I'm trying to insert another document into the entries array using the code below. But not only does that not work, it throws a "Mutating the [[Prototype]] of an object will cause your code to run very slowly..." error. I'd really appreciate some help!
Conversations.update({
channel: "#defaultChannel"
}, {
$push: {
entries: {
message: newMessage,
postedTime: new Date(),
author: "coffeemeup"
}
}
});
Also, I would love to hear suggestions on how to better structure/design this database to build a Slack clone.
If you want to run update operations on clients, you need to use the _id field. Otherwise you will get this error:
Error: Not permitted. Untrusted code may only update documents by ID.
[403]
As a result, get the document first and subsequently use the document's _id to run the update query.
For example:
var conversation = Conversations.findOne({
"channel": "#defaultChannel"
});
Conversations.update({
_id: conversation._id
}, {
$push: {
entries: {
message: "newMessage",
postedTime: new Date(),
author: "coffeemeup"
}
}
});
Here is what the updated conversation document looks like:
{
"_id": "wGixGJgoM6fk57mtN",
"channel": "#defaultChannel",
"createdBy": "coffeemeup",
"timestamp": "2015-07-27T19:25:52.842Z",
"followers": [
"username1",
"username2"
],
"entries": [
{
"message": "this is a message #1",
"postedTime": "2015-07-27T19:25:52.842Z",
"author": "coffeemeup"
},
{
"message": "newMessage",
"postedTime": "2015-07-27T19:27:54.930Z",
"author": "coffeemeup"
}
]
}