I'm a newcomer to neovim and currently having trouble getting DAP to work. More specifically, getting skipFiles to work. I've tried out many different patterns for skipFiles and found no success.
Every time I put a breakpoint in a jest test or a mocha test and it runs into an async method, it takes me to a promiseAfterHook function, then to primiseBeforeHook, then to promiseRejectHandler, then to primiseAfterHook, then to processTicksAndRejections, then to emitHook... I believe these are methods in node_internals that should be ignored.
But then in the test below it doesn't jump to node internal method for console.log and steps over it just fine so this may just be a debugger issue handling async await?
it('testing debugger', async () => {
B 5 console.log('hello');
▎ 4 console.log('hi');
▎ 3 const x = 5 + 50;
▎ 2 const y = 6;
▎ 1 console.log(x + y)
契47 const somePromise = await thisIsTheProblemLine();
Any help would be appreciated. Thank you.
Here are my dap configs:
local home = os.getenv("HOME")
local dap = require("dap")
dap.adapters.node2 = {
type = "executable",
command = "node",
args = { home .. "/personal/microsoft-sucks/vscode-node-debug2/out/src/nodeDebug.js" },
}
dap.configurations.javascript = {
{
name = "Launch",
type = "node2",
request = "launch",
program = "${file}",
cwd = vim.loop.cwd(),
sourceMaps = true,
protocol = "inspector",
console = "integratedTerminal",
},
{
-- For this to work you need to make sure the node process
-- is started with the `--inspect` flag.
name = "Attach to process",
type = "node2",
request = "attach",
processId = require("dap.utils").pick_process,
},
{
name = "Debug Mocha Tests",
type = "node2",
request = "launch",
cwd = vim.loop.cwd(),
runtimeArgs = {
"--inspect-brk",
"${workspaceFolder}/node_modules/mocha/bin/_mocha",
},
sourceMaps = true,
protocol = "inspector",
runtimeExecutable = "node",
args = {"inspect", "${file}" },
port = 9229,
console = "integratedTerminal",
skipFiles = {
"<node_internals>/**",
"node_modules/**",
}
},
}
dap.configurations.typescript = {
{
name = "ts-node (Node2 with ts-node)",
type = "node2",
request = "launch",
cwd = vim.loop.cwd(),
runtimeArgs = { "-r", "ts-node/register" },
runtimeExecutable = "node",
args = { "--inspect", "${file}" },
sourceMaps = true,
skipFiles = { "<node_internals>/**", "node_modules/**" },
},
{
name = "Jest (Node2 with ts-node)",
type = "node2",
request = "launch",
cwd = vim.loop.cwd(),
runtimeArgs = { "--inspect-brk", "${workspaceFolder}/node_modules/.bin/jest" },
runtimeExecutable = "node",
args = { "${file}", "--runInBand", "--coverage", "false" },
sourceMaps = true,
port = 9229,
skipFiles = {
"<node_internals>/**",
"node_modules/**",
},
},
}
https://pastebin.pl/view/81961f9a
Related
I'm testing with two VSCode setups; one running Deno, the other running Nodejs using the Sucrase compiler to transform the code so that I can write native ES6 modules. I have a very simple test: a small Class and a module that imports it. Here is the Deno VSCode setup.
My VSCode explorer panel looks like this.
PLANNER-CODEBASE
.vscode
launch.json
setting.txt
src
plannerFiles
ClassArrayList.js
main.js
log.ts
.gitignore
.prettierrc
config.ts
deps.ts
index.ts
makefile
readMe.txt
tsconfig.json
I run the code using this launch.json entry.
{
"name": "Debug Program",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "-A", "--unstable", "--inspect-brk", "./index.ts"],
"port": 9229,
"console": "integratedTerminal"
},
This is index.ts
import main from './src/plannerFiles/main.js'
main()
This is main.js
const main = () => {
console.log('Starting your Planner App')
import { ArrayList } from './ClassArrayList.js'
let myArrayList = new ArrayList()
let row0 = ['11/22/1968', '29', 'Revolution 9', 'Beatles', 'The Beatles [White Album]']
let row1 = ['1960', '6', 'Fools Rush In', 'Frank Sinatra', "Nice 'N' Easy"]
let row2 = ['11/11/1971', '1', 'One of These Days', 'Pink Floyd', 'Meddle']
myArrayList.add(row0)
myArrayList.add(row1)
myArrayList.add(row2)
myArrayList[5] = 'five'
let xx = myArrayList.length
let xxx = myArrayList.getUpperBound()
let x = myArrayList.item(0)
let y = myArrayList[1]
let zzz = myArrayList[5]
myArrayList.clear()
myArrayList = ['LEVEL0INDENT', 50, 100, 75, 75, 100, 100, 100, 100] //first value is for initial space
let z = myArrayList[1]
debugger
// static clear = (obj) => (obj.length = 0)
// ArrayList.clear(myArrayList)
}
export default main
This is ClassArrayList.js
class ArrayList extends Array {
constructor() {
super()
}
add = (obj) => {
this.push(obj)
}
item = (key) => {
let obj = this.valueOf()[key]
return obj
}
getUpperBound = () => {
return this.valueOf().length - 1
}
clear = () => {
this.valueOf().length = 0
}
}
export { ArrayList }
This is my terminal output.
ramData\chocolatey\bin\deno.exe run -A --unstable --inspect-brk ./index.ts
Debugger listening on ws://127.0.0.1:9229/ws/fd15dc8c-111d-45e4-b09e-651aae5b01c7
error: Expected LParen, got Some(LBrace) at file:///C:/Users/Bruce/Dropbox/Code/DENO%20BACKEND/Planner-Codebase/src/plannerFiles/main.js:4:9
I don't know what's wrong or how to fix it. Any help would be appreciated.
Instead of importing module inside function move outside like this. If you want to load module lazyly use dynamic import
Try this:
import { ArrayList } from './ClassArrayList.js'
const main = () => {
console.log('Starting your Planner App');
let myArrayList = new ArrayList();
let row0 = ['11/22/1968', '29', 'Revolution 9', 'Beatles', 'The Beatles [White Album]']
let row1 = ['1960', '6', 'Fools Rush In', 'Frank Sinatra', "Nice 'N' Easy"]
let row2 = ['11/11/1971', '1', 'One of These Days', 'Pink Floyd', 'Meddle']
myArrayList.add(row0)
myArrayList.add(row1)
myArrayList.add(row2)
myArrayList[5] = 'five'
let xx = myArrayList.length
let xxx = myArrayList.getUpperBound()
let x = myArrayList.item(0)
let y = myArrayList[1]
let zzz = myArrayList[5]
myArrayList.clear()
myArrayList = ['LEVEL0INDENT', 50, 100, 75, 75, 100, 100, 100, 100] //first value is for initial space
let z = myArrayList[1]
debugger
// static clear = (obj) => (obj.length = 0)
// ArrayList.clear(myArrayList)
}
export default main
I am using ServiceNow develop instance to create a table, in which one field is type of list. The values of the list is populated by Outgoing Rest message.
In business rule, I make a hard coded to see how list values shall be what kind of form. The codes lists as below/1/: but when I update the field computer room, the computerlist's value is not populated. It looks like in the image/2/. How to populate values to a list type of field?
/3/ is the json string returned in pretty format. I try to populate hostName to computerlist, but failed.
/1/ scripts in business rule:
(function executeRule(current, previous /*null when async*/ ) {
try {
var r = new sn_ws.RESTMessageV2('x_383581_aiademo2.AIACmdbReq', 'Default GET');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
// var responseObj = JSON.parse(responseBody);
current.computerlist = new Array;
current.computerlist[0] = "c1";
current.computerlist[1] = "c2";
current.computerlist[2] = "c3";
current.assignto = "How to make it as list";
current.update();
} catch (ex) {
var message = ex.message;
}
})(current, previous);
/2/
/3/
{
"code": 200,
"data": {
"dataList": [
{
"hostName": "MysqlServer",
"deviceIp": "192.168.1.40",
"site": "SH",
"hostId": "00000000",
"location": "Room01",
"id": 9381947
},
{
"hostName": "192.168.1.32",
"deviceIp": "192.168.1.32",
"site": "SH",
"hostId": "a8c02001",
"location": "66666",
"id": 9381950
},
{
"hostName": "back-server",
"deviceIp": "192.168.1.42",
"site": "SH",
"hostId": "00000000",
"location": "Room01",
"id": 9381996
},
{
"hostName": "192.168.1.32",
"deviceIp": "192.168.1.32",
"site": "SH",
"hostId": "00-0C-29-E0-31-32",
"location": "Room01",
"id": 9382011
},
{
"hostName": "core-server1",
"deviceIp": "192.168.1.30",
"site": "SH",
"hostId": "00000000",
"location": "Room01",
"id": 9382014
}
]
},
"msg": "success"
}
/4/ business rule script is updated to:
(function executeRule(current, previous /*null when async*/ ) {
try {
var r = new sn_ws.RESTMessageV2('x_383581_aiademo2.AIACmdbReq', 'Default GET');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var responseObj = JSON.parse(responseBody);
current.computerlist = responseObj.data.dataList.hostName;
current.assignto = responseObj.code;
current.update();
} catch (ex) {
var message = ex.message;
}
})(current, previous);
The answer is as follows:
(function executeRule(current, previous /*null when async*/ ) {
try {
var r = new sn_ws.RESTMessageV2('x_383581_aiademo2.AIACmdbReq', 'Default GET');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var responseObj = JSON.parse(responseBody);
var listLength = responseObj.data.dataList.length;
current.responsetest = responseObj.data.dataList[0].hostName;
var temp = new Array(listLength);
for(var j = 0; j<listLength; j++){
temp[j] = responseObj.data.dataList[j].hostName;
}
current.computerlist.setValue(temp);
current.assignto = temp[0];
current.vers = "0.0.1a";
current.description = responseObj.msg;
current.update();
////////////////////////good way///////////////////////////////
///////////current.computerlist.setValue(["1","2","3","4","5"]);
///////////////////////////////////////////////////////////////
} catch (ex) {
var message = ex.message;
}
})(current, previous);
I am trying to get Nightwatch's inbuilt parallel test_workers working with browserstack-local for local url testing.
When running tests without browserstack local, Nightwatch test_workers seem to work just fine. The same is true for running local tests without test_workers enabled.
I have tried the examples found here https://github.com/browserstack/nightwatch-browserstack but none of these uses browserstack-local in combination with Nightwatch test_workers.
When running locally with test_workers I get the following output.
Connecting local
Connected. Now testing...
Process terminated with code 0.
Has anyone else encountered similar issues?
EDIT: I have since resolved this issue and have posted an answer below
I have dumped the relevant configuration files below.
My local.conf.js
nightwatch_config = {
globals_path: 'globals.js',
output_folder: false,
src_folders: ['tests'],
selenium: {
'start_process': false,
'host': 'hub-cloud.browserstack.com',
'port': 80
},
test_workers: {
"enabled": true,
"workers":2
},
test_settings: {
default: {
desiredCapabilities: {
'browserstack.user': process.env.BROWSERSTACK_USER,
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY,
'browserstack.local': true,
'browserstack.debug': false,
}
}
}
};
// Code to copy seleniumhost/port into test settings
for (let i in nightwatch_config.test_settings) {
if (nightwatch_config.test_settings.hasOwnProperty(i)) {
let config = nightwatch_config.test_settings[i];
config['selenium_host'] = nightwatch_config.selenium.host;
config['selenium_port'] = nightwatch_config.selenium.port;
}
}
module.exports = nightwatch_config;
local.runner.js
#!/usr/bin/env node
var Nightwatch = require('nightwatch');
var browserstack = require('browserstack-local');
var bs_local;
process.env.BROWSERSTACK_ID = new Date().getTime();
try {
process.mainModule.filename = "./node_modules/.bin/nightwatch";
// Code to start browserstack local before start of test
console.log("Connecting local");
Nightwatch.bs_local = bs_local = new browserstack.Local();
bs_local.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY }, function (error) {
if (error) throw error;
console.log('Connected. Now testing...');
Nightwatch.cli(function (argv) {
Nightwatch.CliRunner(argv)
.setup(null, function () {
// Code to stop browserstack local after end of parallel test
bs_local.stop(function () { });
})
.runTests(function () {
// Code to stop browserstack local after end of single test
bs_local.stop(function () { });
});
});
});
} catch (ex) {
console.log('There was an error while starting the test runner:\n\n');
process.stderr.write(ex.stack + '\n');
process.exit(2);
}
and my package.json script
node ./local.runner.js -c ./local.conf.js
The issue here was due to the module filename being incorrectly defined in the local.runner.js
process.mainModule.filename = "./node_modules/.bin/nightwatch";
should be pointed directly at the Nightwatch file in its directory.
process.mainModule.filename = "./node_modules/nightwatch/bin/nightwatch";
The difference in these files and the exact reason for this solution working are beyond me.
The answer was derived from the "suite" runner in https://github.com/browserstack/nightwatch-browserstack
It seems you are not specifying browsers. Modify your configuration file to be inline with the following configuration file:
var browserstack = require('browserstack-local');
nightwatch_config = {
src_folders : [ "local" ],
selenium : {
"start_process" : false,
"host" : "hub-cloud.browserstack.com",
"port" : 80
},
test_workers: {
"enabled": true,
"workers":2
},
common_capabilities: {
'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
'browserstack.debug': true,
'browserstack.local': true
},
test_settings: {
default: {},
chrome: {
desiredCapabilities: {
browser: "chrome"
}
},
firefox: {
desiredCapabilities: {
browser: "firefox"
}
},
safari: {
desiredCapabilities: {
browser: "safari"
}
}
}
};
// Code to support common capabilites
for(var i in nightwatch_config.test_settings){
var config = nightwatch_config.test_settings[i];
config['selenium_host'] = nightwatch_config.selenium.host;
config['selenium_port'] = nightwatch_config.selenium.port;
config['desiredCapabilities'] = config['desiredCapabilities'] || {};
for(var j in nightwatch_config.common_capabilities){
config['desiredCapabilities'][j] = config['desiredCapabilities'][j] || nightwatch_config.common_capabilities[j];
}
}
module.exports = nightwatch_config;
According to the docs, I should use a post_poll function to add the missing id field in the response.
How do I add the post_poll function ?
Here's my error:
Results must be an array, got: object,
({"totalevents":83,"events":[{"eventid":10266033,"c)
- Got a result missing the "id" property (83)
Tried following this but it is not clear to me, I'm very new to Zapier-CLI
Update - adding code
This is the function that returns the data:
const listEvents = (z, bundle) => {
console.log('listing events.. ');
let client_id = bundle.inputData.client_id;
const requestOpts = {
url: `https://wccqa.on24.com/wcc/api/v2/client/${client_id}/event`
};
return z.request(requestOpts)
.then((response) => {
return z.JSON.parse(response.content);
});
};
The sample response is the following, with the distiction that I added the id param manually to avoid errors when zapier test|push:
{
"id": 9964513,
"eventid": 9964513,
"archivestart": "2017-09-21T10:30:00-07:00",
"archiveend": "2018-09-21T10:30:00-07:00",
"description": "Zapier Event Test",
"iseliteexpired": "N",
"displaytimezonecd": "America/Bogota",
"eventtype": "Live Webcam ",
"regrequired": true,
"clientid": 22921,
"liveend": "2017-09-21T10:00:00-07:00",
"createtimestamp": "2017-09-21T09:47:44-07:00",
"audienceurl": "https://localhost.on24.com/wcc/r/9964513/C49755A02229BD48E6010848D7C81EF8",
"lastmodified": "2017-09-21T09:47:44-07:00",
"livestart": "2017-09-21T08:45:00-07:00",
"goodafter": "2017-09-21T09:00:00-07:00",
"regnotificationrequired": true,
"isactive": true,
"localelanguagecd": "en"
}
The ACTUAL response from the endpoint the following which is used in the app created in the Web Builder App instead of CLI and works fine:
{
"events": [
{
"eventid": 9964513,
"archivestart": "2017-09-21T10:30:00-07:00",
"archiveend": "2018-09-21T10:30:00-07:00",
"description": "Zapier Event Test",
"iseliteexpired": "N",
"displaytimezonecd": "America/Bogota",
"eventtype": "Live Webcam ",
"regrequired": true,
"clientid": 22921,
"liveend": "2017-09-21T10:00:00-07:00",
"createtimestamp": "2017-09-21T09:47:44-07:00",
"audienceurl": "https://localhost.on24.com/wcc/r/9964513/C49755A02229BD48E6010848D7C81EF8",
"lastmodified": "2017-09-21T09:47:44-07:00",
"livestart": "2017-09-21T08:45:00-07:00",
"goodafter": "2017-09-21T09:00:00-07:00",
"regnotificationrequired": true,
"isactive": true,
"localelanguagecd": "en"
}
],
"totalevents": 1
}
I was thinking something along the line of the following, but how do I register this ?
const postPoll = (event,z,bundle) => {
if(event.key === 'events'){
var results = z.JSON.parse(bundle.request.data).results;
var events = results.events.map(function(event){
event.id = event.eventid;
return event;
});
bundle.request.data = events;
}
};
module.exports = postPoll;
Nice, so you're almost there! CLI apps don't have pre_ and post_ poll methods. Instead, you put any manipulation after the response comes in.
const listEvents = (z, bundle) => {
console.log('listing events.. ');
let client_id = bundle.inputData.client_id;
const requestOpts = {
url: `https://wccqa.on24.com/wcc/api/v2/client/${client_id}/event`
};
return z.request(requestOpts)
.then((response) => {
return z.JSON.parse(response.content);
})
.then(data => {
const events = data.events; // array of events
return events.map(function(e){ // returns array of objects with `id` defined
e.id = e.event_id
return e
})
})
};
I was trying to run a test that had worked the day before and got an error message saying
- Error: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
I added a console.log("hi") in one of my beforeAll() calls and there was no output in the console, so I suspect the error is that beforeAll() is not invoked for some reason.
I'm using the latest jasmine framework in my conf file and some of my tests run when I don't include the beforeAll(), but not all of them. This test was working fine yesterday and I ran it again today without any changes, so I'm not sure what the problem might be. Does anyone else know?
I'll include my conf.js file and part of the test I'm running.
My conf.js file
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
framework: 'jasmine',
directConnect: true,
allScriptsTimeout: 50000,
rootElement: 'html',
untrackOutstandingTimeouts: true,
// suites: {
//HealthCheck: './specs/Health Check/**.js',
//ContectCheck: './specs/Content Check/**.js',
// },
specs: [
// 'specs/submitFeedback.js',
'specs/createTeacherAndStudentOld.js',
// 'specs/temp.js',
// 'specs/manipTeste.js',
],
capabilities: {
browserName: 'chrome'
},
params: {
screenWidth: 1920,
screenHeight: 1080,
siteURL: 'https://alpha.khmath.com',
marketingSiteURL: 'https://knowledgehook.com',
portalUsername: '',
portalPassword: '',
classRedemptionCode: 'testcode1',
contentCheckCourse: 'Grade 9 Academic',
homeWorkCourse: 'Grade 9 Applied',
gameShowCourse: 'Grade 9 Applied',
term: '2016-2017 Full Year',
gameShowSiteUrl: 'https://alpha.khmath.com/play'
},
jasmineNodeOpts: {
defaultTimeoutInterval: 7200000,
print: function() {}
},
onPrepare: function () {
global.helper = require('./helper.js');
global.completeQuestionHelper = require('./pages/student/completeQuestionHelper.js');
global.fs = require('fs');
global.https = require('https');
global.LoginPage = require('./pages/loginPage.js');
global.RegistrationPage = require('./pages/registrationPage.js');
global.TeacherGameShowPage = require('./pages/teacher/teacherGameShowPage.js');
global.TeacherHomePage = require('./pages/teacher/teacherHomePage.js');
global.TeacherMissionPage = require('./pages/teacher/teacherMissionPage.js');
global.TeacherPurchasePage = require('./pages/teacher/teacherPurchasePage.js');
global.TeacherStudentsPage = require('./pages/teacher/teacherStudentsPage.js');
global.TeacherStudentSummaryPage = require('./pages/teacher/teacherStudentSummaryPage.js');
global.TeacherReportPage = require('./pages/teacher/teacherReportPage.js');
global.StudentHomePage = require('./pages/student/studentHomePage.js');
global.StudentAllSkillsPage = require('./pages/student/studentAllSkillsPage.js');
global.StudentSkillPage = require('./pages/student/studentSkillPage.js');
global.StudentGameplayPage = require('./pages/student/studentGameplayPage.js');
global.StudentMissionPage = require('./pages/student/studentMissionPage.js');
global.StudentPortfolioPage = require('./pages/student/StudentPortfolioPage.js');
global.GameShowStudentGameplayPage = require('./pages/gameshow/gameShowStudentGameplayPage.js');
global.GameShowStudentRegistrationPage = require('./pages/gameshow/gameShowStudentRegistrationPage.js');
global.GameShowTeacherGameplayPage = require('./pages/gameshow/gameShowTeacherGameplayPage.js');
global.loginPage = new LoginPage(browser);
global.registrationPage = new RegistrationPage(browser);
global.teacherGameShowPage = new TeacherGameShowPage(browser);
global.teacherHomePage = new TeacherHomePage(browser);
global.teacherMissionPage = new TeacherMissionPage(browser);
global.teacherPurchasePage = new TeacherPurchasePage(browser);
global.teacherStudentsPage = new TeacherStudentsPage(browser);
global.teacherStudentSummaryPage = new TeacherStudentSummaryPage(browser);
global.teacherReportPage = new TeacherReportPage(browser);
global.studentHomePage = new StudentHomePage(browser);
global.studentAllSkillsPage = new StudentAllSkillsPage(browser);
global.studentSkillPage = new StudentSkillPage(browser);
global.studentGameplayPage = new StudentGameplayPage(browser);
global.studentMissionPage = new StudentMissionPage(browser);
global.studentPortfolioPage = new StudentPortfolioPage(browser);
global.gameShowStudentGameplayPage = new GameShowStudentGameplayPage(browser);
global.gameShowStudentRegistrationPage = new GameShowStudentRegistrationPage(browser);
global.gameShowTeacherGameplayPage = new GameShowTeacherGameplayPage(browser);
global.EC = protractor.ExpectedConditions;
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true
},
colors: {
enabled: false,
},
prefixes: {
successful: "O ",
failed: "X ",
},
}));
},
};
My spec file
beforeAll(function () {
console.log('hi');
helper.setBrowserParams(browser);
browser.get(browser.params.siteURL);
});
it('should register a teacher and create a premium class', function () {
//Click Register
loginPage.registerBtn.click();
...
`