Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
// Testcase for returning report as a string via API call
if (process.argv[2] === 'child') {
const nodereport = require('../');
console.log(nodereport.getReport());
} else {
const common = require('./common.js');
const spawnSync = require('child_process').spawnSync;
const tap = require('tap');
const args = [__filename, 'child'];
const child = spawnSync(process.execPath, args);
tap.plan(3);
tap.strictSame(child.stderr.toString(), '',
'Checking no messages on stderr');
const reportFiles = common.findReports(child.pid);
tap.same(reportFiles, [], 'Checking no report files were written');
tap.test('Validating report content', (t) => {
common.validateContent(child.stdout, t, { pid: child.pid,
commandline: process.execPath + ' ' + args.join(' ')
});
});
}
*/
require('chromedriver');
var seleniumWebdriver = require('selenium-webdriver');
var tap = require('tap');
var utils = require('./teacher_registration_utils.js');
var constants = utils.constants;
// Set test url through environment variable
var rootUrl = process.env.ROOT_URL || 'http://localhost:8333';
// chrome driver
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome())
.build();
tap.plan(3);
tap.tearDown(function () {
driver.quit();
});
tap.beforeEach(function () {
driver.get(rootUrl + '/educators/register');
return utils.fillUsernameSlide(driver, seleniumWebdriver)
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver)) // eslint-disable-line no-invalid-this
.then(utils.fillNameSlide.bind(this, driver, seleniumWebdriver)) // eslint-disable-line no-invalid-this
.then(utils.fillPhoneSlide.bind(this, driver, seleniumWebdriver)) // eslint-disable-line no-invalid-this
.then(utils.fillOrganizationSlide.bind(this, driver, seleniumWebdriver)) // eslint-disable-line no-invalid-this
.then(utils.fillAddressSlide.bind(this, driver, seleniumWebdriver)); // eslint-disable-line no-invalid-this
});
tap.test('checkCharacterCountIsCorrect', function (t) {
*/
require('chromedriver');
var seleniumWebdriver = require('selenium-webdriver');
var tap = require('tap');
var utils = require('./teacher_registration_utils.js');
var constants = utils.constants;
// Set test url through environment variable
var rootUrl = process.env.ROOT_URL || 'http://localhost:8333';
// chrome driver
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome())
.build();
tap.plan(2);
tap.tearDown(function () {
driver.quit();
});
tap.beforeEach(function () {
driver.get(rootUrl + '/educators/register');
return utils.fillUsernameSlide(driver, seleniumWebdriver)
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver)); // eslint-disable-line no-invalid-this
});
// attempts to advance the slide without inputting either name, checks that both give the correct error
tap.test('checkFirstNameRequired', function (t) {
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
var errorMessageXPath = '//input[@name="user.name.first"]/following-sibling::' +
'span[@class="help-block validation-message"]/span[contains(text(),' +
.publish('test', 'test', { test: 'test' })
.publish('test', { event: 'test' })
.publish('test', { data: 'test' })
.publish('test', { id: 1, event: 'test' })
.publish('test', { id: 1, event: 'test', data: 'test' })
.publish('test', { id: 1, event: 'test', data: new Buffer('test') })
.publish('test', { id: 1, event: 'test', data: { test: 'test' } })
.publish('test', { id: 1, event: 'test', data: 'test', retry: 1 })
// test default 'retry' option
b.options.retry = 1
res.publish('test', 'test')
.end()
}
test.plan(1)
app.listen(function (err) {
if (err)
test.threw(err)
else
http.get(app.address(), function (res) {
var act = ''
res.on('data', function (chunk) {
act += chunk
})
res.on('end', function () {
test.equal(act, exp)
app.close()
})
})
})
server.on('message', ([type, port]) => {
test.plan(EXPECTED_ATTEMPTS_TO_RECONNECT);
if (type !== 'listening') {
test.fail('must not receive unknown messages');
}
jstp.net.connect(
APP_NAME,
null,
port,
'localhost',
(error, connection) => {
test.assertNot(error, 'must connect to server and perform handshake');
connection.on('error', () => {
// dismiss
});
const driver = helper.buildDriver('www-smoke test-login-failures');
const {
findByCss,
clickCss
} = helper;
var until = webdriver.until;
var username = process.env.SMOKE_USERNAME;
var password = process.env.SMOKE_PASSWORD;
var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
var url = rootUrl + '/users/' + username;
tap.plan(3);
tap.tearDown(function () {
driver.quit();
});
tap.beforeEach(function () {
return driver.get(url);
});
test('Trying to sign in with no password using scratchr2 navbar', t => {
var nonsenseusername = Math.random().toString(36)
.replace(/[^a-z]+/g, '')
.substr(0, 5);
clickCss('.dropdown-toggle')
.then(() => findByCss('form#login input#login_dropdown_username'))
.then((element) => element.sendKeys(nonsenseusername))
}
}
}
function makeErr (path, method) {
var err = new Error('this is fine')
err.syscall = method.replace(/Sync$/, '')
err.code = path.toUpperCase()
return err
}
var fs = require('../')
var t = require('tap')
var errs = ['ENOSYS', 'EINVAL', 'EPERM']
t.plan(errs.length * methods.length)
errs.forEach(function (err) {
methods.forEach(function (method) {
var args = [err]
if (/chmod/.test(method)) {
args.push('some mode')
} else {
args.push('some uid', 'some gid')
}
if (method.match(/Sync$/)) {
t.doesNotThrow(function () {
fs[method].apply(fs, args)
})
} else {
args.push(function (err) {
child.on('exit', (code) => {
tap.plan(3);
tap.equal(code, 0, 'Process exited cleanly');
const reports = common.findReports(child.pid);
tap.equal(reports.length, 1, 'Found reports ' + reports);
const report = reports[0];
const validateOpts = { pid: child.pid, expectedVersions: [],
commandline: child.spawnargs.join(' '), };
common.validate(tap, report, validateOpts);
});
}
'use strict'
const t = require('tap')
const Fastify = require('fastify')
const From = require('..')
const http = require('http')
const get = require('simple-get').concat
const instance = Fastify()
instance.register(From)
t.plan(10)
t.tearDown(instance.close.bind(instance))
const target = http.createServer((req, res) => {
t.pass('request proxied')
t.equal(req.method, 'GET')
res.statusCode = 205
res.setHeader('Content-Type', 'text/plain')
res.setHeader('x-my-header', 'hello!')
res.end('hello world')
})
instance.get('/', (request, reply) => {
reply.from(`http://localhost:${target.address().port}`, {
rewriteHeaders: (headers) => {
t.pass('rewriteHeaders called')
return {
child.on('exit', (code, signal) => {
tap.plan(4);
tap.equal(code, null, 'Process should not exit cleanly');
tap.equal(signal, 'SIGTERM', 'Process should exit with expected signal');
const reports = common.findReports(child.pid);
tap.equal(reports.length, 1, 'Found reports ' + reports);
const report = reports[0];
common.validate(tap, report, {pid: child.pid,
commandline: child.spawnargs.join(' ')
});
});
}