How to use parseOptions method in Testcafe

Best JavaScript code snippet using testcafe

mongo_client_options.test.js

Source:mongo_client_options.test.js Github

copy

Full Screen

...14 const client = new MongoClient('mongodb://localhost:27017');15 expect(client.options).to.be.frozen;16 });17 it('programmatic options should override URI options', function () {18 const options = parseOptions('mongodb://localhost:27017/test?directConnection=true', {19 directConnection: false20 });21 expect(options.directConnection).to.be.false;22 expect(options.hosts).has.length(1);23 expect(options.dbName).to.equal('test');24 expect(options.prototype).to.not.exist;25 });26 it('should rename tls options correctly', function () {27 const filename = `${os.tmpdir()}/tmp.pem`;28 fs.closeSync(fs.openSync(filename, 'w'));29 const options = parseOptions('mongodb://localhost:27017/?ssl=true', {30 tlsCertificateKeyFile: filename,31 tlsCertificateFile: filename,32 tlsCAFile: filename,33 sslCRL: filename,34 tlsCertificateKeyFilePassword: 'tlsCertificateKeyFilePassword',35 sslValidate: false36 });37 fs.unlinkSync(filename);38 /*39 * If set TLS enabled, equivalent to setting the ssl option.40 *41 * ### Additional options:42 *43 * | nodejs option | MongoDB equivalent | type |44 * |:---------------------|----------------------------------------------------|:---------------------------------------|45 * | `ca` | sslCA, tlsCAFile | `string \| Buffer \| Buffer[]` |46 * | `crl` | sslCRL | `string \| Buffer \| Buffer[]` |47 * | `cert` | sslCert, tlsCertificateFile | `string \| Buffer \| Buffer[]` |48 * | `key` | sslKey, tlsCertificateKeyFile | `string \| Buffer \| KeyObject[]` |49 * | `passphrase` | sslPass, tlsCertificateKeyFilePassword | `string` |50 * | `rejectUnauthorized` | sslValidate | `boolean` |51 *52 */53 expect(options).to.not.have.property('tlsCertificateKeyFile');54 expect(options).to.not.have.property('tlsCAFile');55 expect(options).to.not.have.property('sslCRL');56 expect(options).to.not.have.property('tlsCertificateKeyFilePassword');57 expect(options).has.property('ca', '');58 expect(options).has.property('crl', '');59 expect(options).has.property('cert', '');60 expect(options).has.property('key');61 expect(options.key).has.length(0);62 expect(options).has.property('passphrase', 'tlsCertificateKeyFilePassword');63 expect(options).has.property('rejectUnauthorized', false);64 expect(options).has.property('tls', true);65 });66 const ALL_OPTIONS = {67 appName: 'cats',68 auth: { username: 'username', password: 'password' },69 authMechanism: 'SCRAM-SHA-1',70 authMechanismProperties: { SERVICE_NAME: 'service name here' },71 authSource: 'refer to dbName',72 autoEncryption: { bypassAutoEncryption: true },73 checkKeys: true,74 checkServerIdentity: false,75 compressors: 'snappy', // TODO76 connectTimeoutMS: 123,77 directConnection: true,78 dbName: 'test',79 driverInfo: { name: 'MyDriver', platform: 'moonOS' },80 family: 6,81 fieldsAsRaw: { rawField: true },82 forceServerObjectId: true,83 fsync: true,84 heartbeatFrequencyMS: 3,85 ignoreUndefined: false,86 j: true,87 journal: false,88 keepAlive: true,89 keepAliveInitialDelay: 3,90 localThresholdMS: 3,91 logger: new Logger('Testing!'),92 loggerLevel: 'info',93 maxIdleTimeMS: 3,94 maxPoolSize: 2,95 maxStalenessSeconds: 3,96 minInternalBufferSize: 0,97 minPoolSize: 1,98 monitorCommands: true,99 noDelay: true,100 pkFactory: {101 createPk() {102 return 'very unique';103 }104 },105 promiseLibrary: global.Promise,106 promoteBuffers: true,107 promoteLongs: false,108 promoteValues: false,109 raw: true,110 readConcern: new ReadConcern(ReadConcern.AVAILABLE),111 readConcernLevel: ReadConcern.LINEARIZABLE,112 readPreference: ReadPreference.primary,113 readPreferenceTags: [{ loc: 'ny' }],114 replicaSet: 'phil',115 retryReads: false,116 retryWrites: true,117 serializeFunctions: true,118 serverSelectionTimeoutMS: 3,119 servername: 'some tls option',120 serverApi: { version: '1' },121 socketTimeoutMS: 3,122 ssl: true,123 sslPass: 'pass',124 sslValidate: true,125 tls: false,126 tlsAllowInvalidCertificates: true,127 tlsAllowInvalidHostnames: true,128 tlsCertificateKeyFilePassword: 'tls-pass',129 w: 'majority',130 waitQueueTimeoutMS: 3,131 writeConcern: new WriteConcern(2),132 wtimeout: 5,133 wtimeoutMS: 6,134 zlibCompressionLevel: 2135 };136 it('should parse all options from the options object', function () {137 const options = parseOptions('mongodb://localhost:27017/', ALL_OPTIONS);138 // Check consolidated options139 expect(options).has.property('writeConcern');140 expect(options.writeConcern).has.property('w', 2);141 expect(options.writeConcern).has.property('j', true);142 });143 const allURIOptions =144 'mongodb://myName@localhost:27017/test?' +145 [146 'appname=myBestApp',147 'authMechanism=scram-sha-1',148 'authMechanismProperties=opt1:val1',149 'authSource=authDb',150 'compressors=zlib,snappy',151 'connectTimeoutMS=2',152 'directConnection=true',153 'heartbeatFrequencyMS=2',154 'journal=true',155 'localThresholdMS=2',156 'maxIdleTimeMS=2',157 'maxPoolSize=4',158 'maxStalenessSeconds=2',159 'minPoolSize=2',160 'readConcernLevel=local',161 'readPreference=nearest',162 'readPreferenceTags=dc:ny,rack:1',163 'replicaSet=phil',164 'retryReads=true',165 'retryWrites=true',166 'serverSelectionTimeoutMS=2',167 'socketTimeoutMS=2',168 'ssl=true',169 'tls=true',170 'tlsAllowInvalidCertificates=true',171 'tlsAllowInvalidHostnames=true',172 'tlsCertificateKeyFilePassword=PASSWORD',173 'w=majority',174 'waitQueueTimeoutMS=2',175 'wTimeoutMS=2',176 'zlibCompressionLevel=2'177 ].join('&');178 it('should parse all options from the URI string', function () {179 const options = parseOptions(allURIOptions);180 expect(options).has.property('zlibCompressionLevel', 2);181 expect(options).has.property('writeConcern');182 expect(options.writeConcern).has.property('w', 'majority');183 expect(options.writeConcern).has.property('wtimeout', 2);184 });185 it('should ignore undefined and null values in the options object', function () {186 const options = parseOptions('mongodb://localhost:27017/', {187 maxPoolSize: null,188 servername: undefined,189 randomopt: null,190 otherrandomopt: undefined191 });192 // test valid option key with default value193 expect(options).to.have.property('maxPoolSize', 100);194 // test valid option key without default value195 expect(options).not.to.have.property('servername');196 // test invalid option keys that are null/undefined197 expect(options).not.to.have.property('randomopt');198 expect(options).not.to.have.property('otherrandomopt');199 });200 it('should throw an error on unrecognized keys in the options object if they are defined', function () {201 expect(() =>202 parseOptions('mongodb://localhost:27017/', {203 randomopt: 'test'204 })205 ).to.throw(MongoParseError, 'option randomopt is not supported');206 expect(() =>207 parseOptions('mongodb://localhost:27017/', {208 randomopt: 'test',209 randomopt2: 'test'210 })211 ).to.throw(MongoParseError, 'options randomopt, randomopt2 are not supported');212 });213 it('srvHost saved to options for later resolution', function () {214 const options = parseOptions('mongodb+srv://server.example.com/');215 expect(options).has.property('srvHost', 'server.example.com');216 expect(options).has.property('tls', true);217 });218 it('ssl= can be used to set tls=false', function () {219 const options = parseOptions('mongodb+srv://server.example.com/?ssl=false');220 expect(options).has.property('srvHost', 'server.example.com');221 expect(options).has.property('tls', false);222 });223 it('tls= can be used to set tls=false', function () {224 const options = parseOptions('mongodb+srv://server.example.com/?tls=false');225 expect(options).has.property('srvHost', 'server.example.com');226 expect(options).has.property('tls', false);227 });228 it('supports ReadPreference option in url', function () {229 const options = parseOptions('mongodb://localhost/?readPreference=nearest');230 expect(options.readPreference).to.be.an.instanceof(ReadPreference);231 expect(options.readPreference.mode).to.equal('nearest');232 });233 it('supports ReadPreference option in object plain', function () {234 const options = parseOptions('mongodb://localhost', {235 readPreference: { mode: 'nearest', hedge: { enabled: true } }236 });237 expect(options.readPreference).to.be.an.instanceof(ReadPreference);238 expect(options.readPreference.mode).to.equal('nearest');239 expect(options.readPreference.hedge).to.include({ enabled: true });240 });241 it('supports ReadPreference option in object proper class', function () {242 const tag = { rack: 1 };243 const options = parseOptions('mongodb://localhost', {244 readPreference: new ReadPreference('nearest', [tag], { maxStalenessSeconds: 20 })245 });246 expect(options.readPreference).to.be.an.instanceof(ReadPreference);247 expect(options.readPreference.mode).to.equal('nearest');248 expect(options.readPreference.tags).to.be.an('array').that.includes(tag);249 expect(options.readPreference.maxStalenessSeconds).to.equal(20);250 // maxStalenessSeconds sets the minWireVersion251 expect(options.readPreference.minWireVersion).to.be.at.least(5);252 });253 it('supports WriteConcern option in url', function () {254 const options = parseOptions('mongodb://localhost/?w=3');255 expect(options.writeConcern).to.be.an.instanceof(WriteConcern);256 expect(options.writeConcern.w).to.equal(3);257 });258 it('supports WriteConcern option in object plain', function () {259 const options = parseOptions('mongodb://localhost', {260 writeConcern: { w: 'majority', wtimeoutMS: 300 }261 });262 expect(options.writeConcern).to.be.an.instanceof(WriteConcern);263 expect(options.writeConcern.w).to.equal('majority');264 expect(options.writeConcern.wtimeout).to.equal(300);265 });266 it('supports WriteConcern option in object proper class', function () {267 const options = parseOptions('mongodb://localhost', {268 writeConcern: new WriteConcern(5, 200, true)269 });270 expect(options.writeConcern).to.be.an.instanceof(WriteConcern);271 expect(options.writeConcern.w).to.equal(5);272 expect(options.writeConcern.wtimeout).to.equal(200);273 expect(options.writeConcern.j).to.equal(true);274 });275 it('supports ReadConcern option in url', function () {276 const options = parseOptions('mongodb://localhost/?readConcernLevel=available');277 expect(options.readConcern).to.be.an.instanceof(ReadConcern);278 expect(options.readConcern.level).to.equal('available');279 });280 it('supports ReadConcern option in object plain', function () {281 const options = parseOptions('mongodb://localhost', {282 readConcern: { level: 'linearizable' }283 });284 expect(options.readConcern).to.be.an.instanceof(ReadConcern);285 expect(options.readConcern.level).to.equal('linearizable');286 });287 it('supports ReadConcern option in object proper class', function () {288 const options = parseOptions('mongodb://localhost', {289 readConcern: new ReadConcern('snapshot')290 });291 expect(options.readConcern).to.be.an.instanceof(ReadConcern);292 expect(options.readConcern.level).to.equal('snapshot');293 });294 it('supports Credentials option in url', function () {295 const options = parseOptions('mongodb://USERNAME:PASSWORD@localhost/');296 expect(options.credentials).to.be.an.instanceof(MongoCredentials);297 expect(options.credentials.username).to.equal('USERNAME');298 expect(options.credentials.password).to.equal('PASSWORD');299 expect(options.credentials.source).to.equal('admin');300 });301 it('supports Credentials option in url with db', function () {302 const options = parseOptions('mongodb://USERNAME:PASSWORD@localhost/foo');303 expect(options.credentials).to.be.an.instanceof(MongoCredentials);304 expect(options.credentials.username).to.equal('USERNAME');305 expect(options.credentials.password).to.equal('PASSWORD');306 expect(options.credentials.source).to.equal('foo');307 });308 it('supports Credentials option in auth object plain', function () {309 const options = parseOptions('mongodb://localhost/', {310 auth: { username: 'USERNAME', password: 'PASSWORD' }311 });312 expect(options.credentials).to.be.an.instanceof(MongoCredentials);313 expect(options.credentials.username).to.equal('USERNAME');314 expect(options.credentials.password).to.equal('PASSWORD');315 });316 it('transforms tlsAllowInvalidCertificates and tlsAllowInvalidHostnames correctly', function () {317 const optionsTrue = parseOptions('mongodb://localhost/', {318 tlsAllowInvalidCertificates: true,319 tlsAllowInvalidHostnames: true320 });321 expect(optionsTrue.rejectUnauthorized).to.equal(false);322 expect(optionsTrue.checkServerIdentity).to.be.a('function');323 expect(optionsTrue.checkServerIdentity()).to.equal(undefined);324 const optionsFalse = parseOptions('mongodb://localhost/', {325 tlsAllowInvalidCertificates: false,326 tlsAllowInvalidHostnames: false327 });328 expect(optionsFalse.rejectUnauthorized).to.equal(true);329 expect(optionsFalse.checkServerIdentity).to.equal(undefined);330 const optionsUndefined = parseOptions('mongodb://localhost/');331 expect(optionsUndefined.rejectUnauthorized).to.equal(undefined);332 expect(optionsUndefined.checkServerIdentity).to.equal(undefined);333 });334 it('transforms tlsInsecure correctly', function () {335 const optionsTrue = parseOptions('mongodb://localhost/', {336 tlsInsecure: true337 });338 expect(optionsTrue.rejectUnauthorized).to.equal(false);339 expect(optionsTrue.checkServerIdentity).to.be.a('function');340 expect(optionsTrue.checkServerIdentity()).to.equal(undefined);341 const optionsFalse = parseOptions('mongodb://localhost/', {342 tlsInsecure: false343 });344 expect(optionsFalse.rejectUnauthorized).to.equal(true);345 expect(optionsFalse.checkServerIdentity).to.equal(undefined);346 const optionsUndefined = parseOptions('mongodb://localhost/');347 expect(optionsUndefined.rejectUnauthorized).to.equal(undefined);348 expect(optionsUndefined.checkServerIdentity).to.equal(undefined);349 });350 describe('serverApi', function () {351 it('is supported as a client option when it is a valid ServerApiVersion string', function () {352 const validVersions = Object.values(ServerApiVersion);353 expect(validVersions.length).to.be.at.least(1);354 for (const version of validVersions) {355 const result = parseOptions('mongodb://localhost/', {356 serverApi: version357 });358 expect(result).to.have.property('serverApi').deep.equal({ version });359 }360 });361 it('is supported as a client option when it is an object with a valid version property', function () {362 const validVersions = Object.values(ServerApiVersion);363 expect(validVersions.length).to.be.at.least(1);364 for (const version of validVersions) {365 const result = parseOptions('mongodb://localhost/', {366 serverApi: { version }367 });368 expect(result).to.have.property('serverApi').deep.equal({ version });369 }370 });371 it('is not supported as a client option when it is an invalid string', function () {372 expect(() =>373 parseOptions('mongodb://localhost/', {374 serverApi: 'bad'375 })376 ).to.throw(/^Invalid server API version=bad;/);377 });378 it('is not supported as a client option when it is a number', function () {379 expect(() =>380 parseOptions('mongodb://localhost/', {381 serverApi: 1382 })383 ).to.throw(/^Invalid `serverApi` property;/);384 });385 it('is not supported as a client option when it is an object without a specified version', function () {386 expect(() =>387 parseOptions('mongodb://localhost/', {388 serverApi: {}389 })390 ).to.throw(/^Invalid `serverApi` property;/);391 });392 it('is not supported as a client option when it is an object with an invalid specified version', function () {393 expect(() =>394 parseOptions('mongodb://localhost/', {395 serverApi: { version: 1 }396 })397 ).to.throw(/^Invalid server API version=1;/);398 expect(() =>399 parseOptions('mongodb://localhost/', {400 serverApi: { version: 'bad' }401 })402 ).to.throw(/^Invalid server API version=bad;/);403 });404 it('is not supported as a URI option even when it is a valid ServerApiVersion string', function () {405 expect(() => parseOptions('mongodb://localhost/?serverApi=1')).to.throw(406 'URI cannot contain `serverApi`, it can only be passed to the client'407 );408 });409 });...

Full Screen

Full Screen

connection_string.test.js

Source:connection_string.test.js Github

copy

Full Screen

...25 const optionsWithUser = {26 authMechanism: 'SCRAM-SHA-1',27 auth: { user: 'testing', password: 'llamas' }28 };29 expect(() => parseOptions('mongodb://localhost', optionsWithUser)).to.throw(MongoParseError);30 });31 it('should support auth passed with username', function () {32 const optionsWithUsername = {33 authMechanism: 'SCRAM-SHA-1',34 auth: { username: 'testing', password: 'llamas' }35 };36 const options = parseOptions('mongodb://localhost', optionsWithUsername);37 expect(options.credentials).to.containSubset({38 source: 'admin',39 username: 'testing',40 password: 'llamas'41 });42 });43 it('should provide a default port if one is not provided', function () {44 const options = parseOptions('mongodb://hostname');45 expect(options.hosts[0].socketPath).to.be.undefined;46 expect(options.hosts[0].host).to.be.a('string');47 expect(options.hosts[0].port).to.equal(27017);48 });49 it('should parse multiple readPreferenceTags', function () {50 const options = parseOptions(51 'mongodb://hostname?readPreferenceTags=bar:foo&readPreferenceTags=baz:bar'52 );53 expect(options.readPreference.tags).to.deep.equal([{ bar: 'foo' }, { baz: 'bar' }]);54 });55 it('should parse boolean values', function () {56 let options = parseOptions('mongodb://hostname?retryWrites=1');57 expect(options.retryWrites).to.equal(true);58 options = parseOptions('mongodb://hostname?retryWrites=false');59 expect(options.retryWrites).to.equal(false);60 options = parseOptions('mongodb://hostname?retryWrites=t');61 expect(options.retryWrites).to.equal(true);62 });63 it('should parse compression options', function () {64 const options = parseOptions('mongodb://localhost/?compressors=zlib&zlibCompressionLevel=4');65 expect(options).to.have.property('compressors');66 expect(options.compressors).to.include('zlib');67 expect(options.zlibCompressionLevel).to.equal(4);68 });69 it('should parse `readConcernLevel`', function () {70 const options = parseOptions('mongodb://localhost/?readConcernLevel=local');71 expect(options).to.have.property('readConcern');72 expect(options.readConcern.level).to.equal('local');73 });74 it('should parse `authMechanismProperties`', function () {75 const options = parseOptions(76 'mongodb://user%40EXAMPLE.COM:secret@localhost/?authMechanismProperties=SERVICE_NAME:other,SERVICE_REALM:blah,CANONICALIZE_HOST_NAME:true&authMechanism=GSSAPI'77 );78 expect(options.credentials.mechanismProperties).to.deep.include({79 SERVICE_NAME: 'other',80 SERVICE_REALM: 'blah',81 CANONICALIZE_HOST_NAME: true82 });83 expect(options.credentials.mechanism).to.equal(AuthMechanism.MONGODB_GSSAPI);84 });85 it('should parse a numeric authSource with variable width', function () {86 const options = parseOptions('mongodb://test@localhost/?authSource=0001');87 expect(options.credentials.source).to.equal('0001');88 });89 it('should parse a replicaSet with a leading number', function () {90 const options = parseOptions('mongodb://localhost/?replicaSet=123abc');91 expect(options).to.have.property('replicaSet');92 expect(options.replicaSet).to.equal('123abc');93 });94 describe('validation', function () {95 it('should validate compressors options', function () {96 expect(() => parseOptions('mongodb://localhost/?compressors=bunnies')).to.throw(97 MongoParseError,98 'bunnies is not a valid compression mechanism'99 );100 });101 it('should validate authMechanism', function () {102 expect(() => parseOptions('mongodb://localhost/?authMechanism=DOGS')).to.throw(103 MongoParseError,104 'authMechanism one of MONGODB-AWS,MONGODB-CR,DEFAULT,GSSAPI,PLAIN,SCRAM-SHA-1,SCRAM-SHA-256,MONGODB-X509, got DOGS'105 );106 });107 it('should validate readPreference', function () {108 expect(() => parseOptions('mongodb://localhost/?readPreference=llamasPreferred')).to.throw(109 MongoDriverError, // not parse Error b/c thrown from ReadPreference construction110 'Invalid read preference mode "llamasPreferred"'111 );112 });113 it('should validate non-equal tls values', function () {114 expect(() => parseOptions('mongodb://localhost/?tls=true&tls=false')).to.throw(115 MongoParseError,116 'All values of tls must be the same.'117 );118 });119 });120 describe('spec tests', function () {121 const suites = loadSpecTests('connection-string').concat(loadSpecTests('auth'));122 for (const suite of suites) {123 describe(suite.name, function () {124 for (const test of suite.tests) {125 it(`${test.description}`, function () {126 if (skipTests.includes(test.description)) {127 return this.skip();128 }129 const message = `"${test.uri}"`;130 const valid = test.valid;131 if (valid) {132 const options = parseOptions(test.uri);133 expect(options, message).to.be.ok;134 if (test.hosts) {135 for (const [index, { host, port }] of test.hosts.entries()) {136 expect(options.hosts[index], message).to.satisfy(e => {137 return e.host === host || e.socketPath === host;138 });139 if (typeof port === 'number') expect(options.hosts[index].port).to.equal(port);140 }141 }142 if (test.auth && test.auth.db != null) {143 expect(options.dbName, message).to.equal(test.auth.db);144 }145 if (test.auth && test.auth.username) {146 expect(options.credentials, message).to.exist;147 if (test.auth.db != null) {148 expect(options.credentials.source, message).to.equal(test.auth.db);149 }150 if (test.auth.username != null) {151 expect(options.credentials.username, message).to.equal(test.auth.username);152 }153 if (test.auth.password != null) {154 expect(options.credentials.password, message).to.equal(test.auth.password);155 }156 }157 if (test.options) {158 for (const [optionKey, optionValue] of Object.entries(test.options)) {159 switch (optionKey) {160 case 'authmechanism':161 expect(options.credentials.mechanism, message).to.eq(optionValue);162 break;163 case 'authmechanismproperties':164 expect(options.credentials.mechanismProperties, message).to.deep.eq(165 optionValue166 );167 break;168 case 'replicaset':169 expect(options.replicaSet, message).to.equal(optionValue);170 break;171 case 'w':172 expect(options.writeConcern.w).to.equal(optionValue);173 break;174 default:175 throw Error(`This options is not covered by the spec test: ${optionKey}`);176 }177 }178 }179 } else {180 expect(() => parseOptions(test.uri), message).to.throw();181 }182 });183 }184 });185 }186 });...

Full Screen

Full Screen

common.js

Source:common.js Github

copy

Full Screen

...24 }, TypeError);25});26test('parseOptions (invalid option in options object)', t => {27 t.throws(() => {28 common.parseOptions({ q: 'some string value' }, {29 R: 'recursive',30 f: 'force',31 r: 'reverse',32 });33 }, common.CommandError);34});35test('parseOptions (without a hyphen in the string)', t => {36 t.throws(() => {37 common.parseOptions('f', {38 f: 'force',39 });40 }, Error);41});42test('parseOptions (opt is not a string/object)', t => {43 t.throws(() => {44 common.parseOptions(1, {45 f: 'force',46 });47 }, TypeError);48});49test('parseOptions (map is not an object)', t => {50 t.throws(() => {51 common.parseOptions('-f', 27);52 }, TypeError);53});54test('parseOptions (errorOptions is not an object)', t => {55 t.throws(() => {56 common.parseOptions('-f', {57 f: 'force',58 }, 'not a valid errorOptions');59 }, TypeError);60});61test('parseOptions (unrecognized string option)', t => {62 t.throws(() => {63 common.parseOptions('-z', {64 f: 'force',65 });66 }, common.CommandError);67});68test('parseOptions (unrecognized option in Object)', t => {69 t.throws(() => {70 common.parseOptions({ '-c': 7 }, {71 f: 'force',72 });73 });74});75test('parseOptions (invalid type)', t => {76 t.throws(() => {77 common.parseOptions(12, {78 R: 'recursive',79 f: 'force',80 r: 'reverse',81 });82 });83});84test('convertErrorOutput: no args', t => {85 t.throws(() => {86 common.convertErrorOutput();87 }, TypeError);88});89test('convertErrorOutput: input must be a vanilla string', t => {90 t.throws(() => {91 common.convertErrorOutput(3);92 }, TypeError);93 t.throws(() => {94 common.convertErrorOutput({});95 }, TypeError);96});97//98// Valids99//100//101// common.convertErrorOutput()102//103test('convertErrorOutput: nothing to convert', t => {104 const input = 'hello world';105 const result = common.convertErrorOutput(input);106 t.is(result, input);107});108test('convertErrorOutput: does not change forward slash', t => {109 const input = 'dir/sub/file.txt';110 const result = common.convertErrorOutput(input);111 t.is(result, input);112});113test('convertErrorOutput: changes backslashes to forward slashes', t => {114 const input = 'dir\\sub\\file.txt';115 const result = common.convertErrorOutput(input);116 t.is(result, 'dir/sub/file.txt');117});118//119// common.expand()120//121test('single file, array syntax', t => {122 const result = common.expand(['test/resources/file1.txt']);123 t.deepEqual(result, ['test/resources/file1.txt']);124});125test('multiple file, glob syntax, * for file name', t => {126 const result = common.expand(['test/resources/file*.txt']);127 t.deepEqual(result.sort(), ['test/resources/file1.txt', 'test/resources/file2.txt'].sort());128});129test('multiple file, glob syntax, * for directory name', t => {130 const result = common.expand(['test/r*/file*.txt']);131 t.deepEqual(result.sort(), ['test/resources/file1.txt', 'test/resources/file2.txt'].sort());132});133test('multiple file, glob syntax, ** for directory name', t => {134 const result = common.expand(['test/resources/**/file*.js']);135 t.deepEqual(136 result.sort(),137 ['test/resources/file1.js', 'test/resources/file2.js', 'test/resources/ls/file1.js', 'test/resources/ls/file2.js'].sort()138 );139});140test('broken links still expand', t => {141 const result = common.expand(['test/resources/b*dlink']);142 t.deepEqual(result, ['test/resources/badlink']);143});144test('empty array', t => {145 const result = common.expand([]);146 t.deepEqual(result, []);147});148test('empty string', t => {149 const result = common.expand(['']);150 t.deepEqual(result, ['']);151});152test('non-string', t => {153 const result = common.expand([5]);154 t.deepEqual(result, [5]);155});156//157// common.buffer()158//159test('common.buffer returns buffer', t => {160 const buf = common.buffer();161 t.truthy(buf instanceof Buffer);162 t.is(buf.length, 64 * 1024);163});164test('common.buffer with explicit length', t => {165 const buf = common.buffer(20);166 t.truthy(buf instanceof Buffer);167 t.is(buf.length, 20);168});169test('common.buffer with different config.bufLength', t => {170 common.config.bufLength = 20;171 const buf = common.buffer();172 t.truthy(buf instanceof Buffer);173 t.is(buf.length, 20);174});175test('common.parseOptions (normal case)', t => {176 const result = common.parseOptions('-Rf', {177 R: 'recursive',178 f: 'force',179 r: 'reverse',180 });181 t.truthy(result.recursive);182 t.truthy(result.force);183 t.falsy(result.reverse);184});185test('common.parseOptions (with mutually-negating options)', t => {186 const result = common.parseOptions('-f', {187 n: 'no_force',188 f: '!no_force',189 R: 'recursive',190 });191 t.falsy(result.recursive);192 t.falsy(result.no_force);193 t.is(result.force, undefined); // this key shouldn't exist194});195test(196 'common.parseOptions (the last of the conflicting options should hold)',197 t => {198 const options = {199 n: 'no_force',200 f: '!no_force',201 R: 'recursive',202 };203 let result = common.parseOptions('-fn', options);204 t.false(result.recursive);205 t.truthy(result.no_force);206 t.is(result.force, undefined); // this key shouldn't exist207 result = common.parseOptions('-nf', options);208 t.false(result.recursive);209 t.false(result.no_force);210 t.is(result.force, undefined); // this key shouldn't exist211 }212);213test('common.parseOptions using an object to hold options', t => {214 const result = common.parseOptions({ '-v': 'some text here' }, {215 v: 'value',216 f: 'force',217 r: 'reverse',218 });219 t.is(result.value, 'some text here');220 t.false(result.force);221 t.false(result.reverse);222});223test('common.parseOptions throws when passed a string not starting with "-"', t => {224 t.throws(() => {225 common.parseOptions('a', { '-a': 'throws' });226 }, Error, "Options string must start with a '-'");227});228test('common.parseOptions allows long options', t => {229 const result = common.parseOptions({ value: true }, {230 v: 'value',231 });232 t.truthy(result.value);233});234test('common.parseOptions allows long options with values', t => {235 const someObject = {};236 const result = common.parseOptions({ value: someObject }, {237 v: 'value',238 });239 t.is(result.value, someObject);240});241test('common.parseOptions throws for unknown long option', t => {242 t.throws(() => {243 common.parseOptions({ throws: true }, {244 v: 'value',245 });246 }, common.CommandError);247});248test('common.parseOptions with -- argument', t => {249 const result = common.parseOptions('--', {250 R: 'recursive',251 f: 'force',252 r: 'reverse',253 });254 t.falsy(result.recursive);255 t.falsy(result.force);256 t.falsy(result.reverse);257});258test('Some basic tests on the ShellString type', t => {259 const result = shell.ShellString('foo');260 t.is(result.toString(), 'foo');261 t.is(result.stdout, 'foo');262 t.is(result.stderr, undefined);263 t.truthy(result.to);...

Full Screen

Full Screen

core.js

Source:core.js Github

copy

Full Screen

1const parse = require('./parse');2const jsCore = require('../js-core/core');3const htmlCore = require('../html-core/core')4const NodePath = require('../NodePath');5const core = {6 getAstsBySelector(ast, selector, { parseOptions } = {}) {7 parseOptions = Object.assign({}, parseOptions);8 let newAst = ast;9 if (selector == '<template></template>') {10 parseOptions.language = 'html';11 parseOptions.rootLanguage = 'vue';12 if (ast.templateAst) {13 newAst = ast.templateAst;14 } else {15 ast.templateAst = core.getTemplate(ast);16 newAst = ast.templateAst;17 }18 } else if (selector == '<script></script>') {19 parseOptions.language = 'js'20 parseOptions.rootLanguage = 'vue';21 if (ast.scriptAst) {22 newAst = ast.scriptAst;23 } else {24 ast.scriptAst = core.getScript(ast, { parseOptions });25 newAst = ast.scriptAst;26 }27 } else if (selector == '<script setup></script>') {28 parseOptions.language = 'js'29 parseOptions.rootLanguage = 'vue';30 if (ast.scriptSetupAst) {31 newAst = ast.scriptSetupAst;32 } else {33 ast.scriptSetupAst = core.getScript(ast, { isSetup: true, parseOptions });34 newAst = ast.scriptSetupAst;35 }36 }37 return { nodePathList: newAst ? [newAst] : [], matchWildCardList: [], extra: { parseOptions } }38 },39 getTemplate(ast) {40 // 仅针对vue,取template,后续通过htmlcore处理41 if (ast.template) {42 const template = htmlCore.buildAstByAstStr(43 ast.template.content,44 {},45 {46 isProgram: true,47 parseOptions: { language: 'html' }48 }49 );50 return new NodePath(template);51 } else {52 return undefined;53 }54 },55 getScript(ast, { isSetup = false, parseOptions } = {} ) {56 // 仅针对vue,取script,后续通过jscore处理57 let content;58 if (isSetup && ast.scriptSetup) {59 content = ast.scriptSetup.content;60 } else if (!isSetup && ast.script) {61 content = ast.script.content62 // const content = ast.script.content.replace(/\n/g, '')63 }64 if (content) {65 const script = jsCore.buildAstByAstStr(66 content, {},67 {68 isProgram: true,69 parseOptions70 }71 );72 return new NodePath(script);73 } else {74 return undefined;75 }76 },77 buildAstByAstStr(str, astPatialMap = {}, { isProgram = false, parseOptions } = {}) {78 try {79 const program = parse(str, parseOptions);80 core.parseOptions = parseOptions;81 if (program) {82 if (isProgram) {83 return program;84 } else {85 if (program.template && program.template.ast) {86 return program.template87 } else return null88 }89 } else {90 return null;91 }92 } catch(e) {93 console.log('buildAstByAstStr failed:' + e)94 }95 }96}...

Full Screen

Full Screen

$.js

Source:$.js Github

copy

Full Screen

1const jsCore = require('./js-core/core');2const htmlCore = require('./html-core/core');3const vueCore = require('./vue-core/core');4const NodePath = require('./NodePath');5const AST = require('./Ast');6// const build = require('./build-node');7const loadFile = require('./file-tool/read-file');8const writeFile = require('./file-tool/write-file');9const pkg = require('../package.json');10const langCoreMap = {11 'vue': vueCore,12 'html': htmlCore,13 'js': jsCore14}15function getCore(parseOptions = {}) {16 let core = jsCore17 if (parseOptions.language && langCoreMap[parseOptions.language]) {18 core = langCoreMap[parseOptions.language]19 }20 if (parseOptions.html) {21 core = htmlCore22 parseOptions.language = 'html'23 }24 return core25}26const main = (code, options = {}) => {27 code = code || '';28 let node;29 let nodePath;30 let parseOptions;31 let astFragment;32 let isProgram = 33 options.isProgram === undefined || options.isProgram === true;34 if (typeof options.parseOptions == 'object') {35 parseOptions = options.parseOptions;36 }37 if (typeof options.astFragment == 'object') {38 astFragment = options.astFragment;39 }40 if (typeof code == 'string') {41 try {42 const core = getCore(parseOptions)43 node = core.buildAstByAstStr(44 code,45 astFragment, 46 {47 parseOptions,48 isProgram49 }50 );51 } catch (e) {52 return { 53 src: code,54 error: `Only correct js / html / vue could be parse successfully, please check the code or parseOptions!`55 }56 }57 nodePath = new NodePath(node);58 } else if (code.nodeType) {59 nodePath = new NodePath(code);60 } else if (code.type) {61 // 传入ast node对象62 nodePath = new NodePath(code);63 } else if (code.node && code.parent) {64 // 传入nodePath对象65 nodePath = code;66 } else {67 throw new Error('$ failed! invalid input! accept code / ast node / nodePath');68 }69 let ast = new AST(nodePath, { parseOptions, rootNode: nodePath });70 return ast;71};72main.loadFile = (filePath, { parseOptions } = {}) => {73 const code = loadFile(filePath).toString();74 return main(code, { parseOptions })75};76main.writeFile = writeFile;77main.version = pkg.version;...

Full Screen

Full Screen

parse-options.js

Source:parse-options.js Github

copy

Full Screen

1'use strict';2angular.module('mgcrea.ngStrap.helpers.parseOptions', [])3 .provider('$parseOptions', function () {4 var defaults = this.defaults = {5 regexp: /^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(.*?)(?:\s+track\s+by\s+(.*?))?$/6 };7 this.$get = function ($parse, $q) {8 function ParseOptionsFactory (attr, config) {9 var $parseOptions = {};10 // Common vars11 var options = angular.extend({}, defaults, config);12 $parseOptions.$values = [];13 // Private vars14 var match;15 var displayFn;16 var valueName;17 /* eslint-disable no-unused-vars */18 var keyName;19 var groupByFn;20 /* eslint-enable no-unused-vars */21 var valueFn;22 var valuesFn;23 $parseOptions.init = function () {24 $parseOptions.$match = match = attr.match(options.regexp);25 displayFn = $parse(match[2] || match[1]);26 valueName = match[4] || match[6];27 keyName = match[5];28 groupByFn = $parse(match[3] || '');29 valueFn = $parse(match[2] ? match[1] : valueName);30 valuesFn = $parse(match[7]);31 };32 $parseOptions.valuesFn = function (scope, controller) {33 return $q.when(valuesFn(scope, controller))34 .then(function (values) {35 if (!angular.isArray(values)) {36 values = [];37 }38 $parseOptions.$values = values.length ? parseValues(values, scope) : [];39 return $parseOptions.$values;40 });41 };42 $parseOptions.displayValue = function (modelValue) {43 var scope = {};44 scope[valueName] = modelValue;45 return displayFn(scope);46 };47 // Private functions48 function parseValues (values, scope) {49 return values.map(function (match, index) {50 var locals = {};51 var label;52 var value;53 locals[valueName] = match;54 label = displayFn(scope, locals);55 value = valueFn(scope, locals);56 return {label: label, value: value, index: index};57 });58 }59 $parseOptions.init();60 return $parseOptions;61 }62 return ParseOptionsFactory;63 };...

Full Screen

Full Screen

ParseOptions.js

Source:ParseOptions.js Github

copy

Full Screen

1const Utils = require('../../Utils')2/**3 * Represents a ParseOptions object as specified in the handlebars type4 * definition.5 *6 * @typedef {Object} ParseOptions7 *8 * @property {(string|undefined)} srcName - Passed to generate the9 * source map for the input file.10 *11 * @property {boolean} ignoreStandalone - Disables standalone tag12 * removal when set to true. When set, blocks and partials that are on13 * their own line will not remove the whitespace on that line.14 */15/**16 * Produce an updated ParseOptions object with the properties from the17 * given Partial<ParseOptions>. This alter the original ParseOptions18 * Object.19 *20 * @param {Partial<ParseOptions>}21 * @param {ParseOptions} parseOptions - context22 *23 * @return {ParseOptions}24 */25function patch_context26 ( { srcName27 , ignoreStandalone28 }29 , context30 ) {31 Utils.set_context_property32 ( srcName33 , undefined34 , 'srcName'35 , context36 )37 38 Utils.set_context_property39 ( ignoreStandalone40 , false 41 , 'ignoreStandalone'42 , context43 )44 return context45 }46module.exports.patch_context = patch_context47/**48 * Produce a new ParseOptions object with the properties from the given49 * Partial<ParseOptions>.50 *51 * @param {Partial<ParseOptions>} parseOptionsPartial52 * @return {ParseOptions}53 */54function create55 ( parseOptionsPartial56 ) {57 return patch_context(parseOptionsPartial, {})58 }59module.exports.create = create60/**61 * Produce an updated ParseOptions object with the properties from the62 * given Partial<ParseOptions>. This does not alter the original63 * ParseOptions.64 *65 * @param {Partial<ParseOptions>} parseOptionsPartial66 * @param {ParseOptions} initialParseOptions67 *68 * @return {parseOptions}69 */70function patch71 ( parseOptionsPartial72 , initialParseOptions73 ) {74 return (75 patch_context76 ( parseOptionsPartial, { ... initialParseOptions}77 )78 )79 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1#!/usr/bin/env node2const parseArgs = require('minimist')3const { resolveModule } = require('../src/resolve_module')4const Help = require('../src/help')5const Version = require('../src/version')6const globalParseOptions = {7 boolean: [8 'help',9 'version',10 'verbose'11 ],12 alias: {13 help: 'h',14 version: 'v',15 verbose: 'V'16 },17 stopEarly: true18}19const { _: subArgv, ...options } = parseArgs(process.argv.slice(2), globalParseOptions)20void async function () {21 // Early exits22 if (options.help) {23 await Help.handler({ _: [] }, true)24 }25 if (options.version) {26 await Version.handler({ _: [] })27 }28 // Subcommand delegation29 const subcommand = subArgv[0]30 const mod = resolveModule(subcommand)31 if (!mod) {32 await Help.handler({ _: [ subcommand ] }, true)33 }34 const parseOptions = mod.parseOptions || {}35 parseOptions.stopEarly = true36 if (parseOptions.boolean == undefined) {37 parseOptions.boolean = []38 }39 parseOptions.boolean.push('help', 'verbose')40 if (parseOptions.alias == undefined) {41 parseOptions.alias = {}42 }43 parseOptions.alias.help = 'h'44 parseOptions.alias.verbose = 'V'45 const subOptions = parseArgs(subArgv.slice(1), parseOptions)46 subOptions.verbose = subOptions.verbose || options.verbose47 if (subOptions.help) {48 await Help.handler({ _: [ subcommand ] })49 }50 await mod.handler(subOptions)51}().catch((error) => {52 console.error(error.message)53 process.exit(1)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const TestCafe = require('testcafe');2TestCafe.createRunner()3 .src('test.js')4 .browsers('chrome')5 .run({6 })7 .then(failedCount => {8 console.log('Tests failed: ' + failedCount);9 });10const TestCafe = require('testcafe');11TestCafe.createRunner()12 .src('test.js')13 .browsers('chrome')14 .run({15 })16 .then(failedCount => {17 console.log('Tests failed: ' + failedCount);18 });19const TestCafe = require('testcafe');20TestCafe.createRunner()21 .src('test.js')22 .browsers('chrome')23 .run({24 })25 .then(failedCount => {26 console.log('Tests failed: ' + failedCount);27 });28const TestCafe = require('testcafe');29TestCafe.createRunner()30 .src('test.js')31 .browsers('chrome')32 .run({33 })34 .then(failedCount => {35 console.log('Tests failed: ' + failedCount);36 });37const TestCafe = require('testcafe');38TestCafe.createRunner()39 .src('test.js')40 .browsers('chrome')41 .run({42 })43 .then(failedCount => {44 console.log('Tests failed: ' + failedCount);45 });46const TestCafe = require('testcafe');47TestCafe.createRunner()48 .src('test.js')49 .browsers('chrome')50 .run({51 })52 .then(failedCount => {53 console.log('Tests failed: ' + failedCount);54 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const createTestCafe = require('testcafe');2const parseOptions = require('testcafe/lib/cli/option-parser').parseOptions;3const options = parseOptions([4]);5createTestCafe('localhost', 1337, 1338)6 .then(testcafe => {7 .createRunner()8 .src('test.js')9 .browsers('chrome')10 .run(options)11 .catch(error => {12 console.error(error);13 });14 });15test('test', async t => {16 .setNativeDialogHandler(() => true)17 .click('#button');18});19test('test', async t => {20 .setNativeDialogHandler(() => true)21 .click('#button');22});23test('test', async t => {24 .setNativeDialogHandler(() => true)25 .click('#button');26});27test('test', async t => {28 .setNativeDialogHandler(() => true)29 .click('#button');30});31test('test', async t => {32 .setNativeDialogHandler(() => true)33 .click('#button');34});35test('test', async t => {36 .setNativeDialogHandler(() => true)37 .click('#button');38});39test('test', async t => {40 .setNativeDialogHandler(() => true)41 .click('#button');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseOptions } from 'testcafe';2const options = parseOptions(process.argv.slice(2));3console.log(options);4{5 "scripts": {6 }7}8{ browsers: [ 'chrome:headless' ], port1: 1337 }

Full Screen

Using AI Code Generation

copy

Full Screen

1const createTestCafe = require('testcafe');2const parseOptions = require('testcafe/lib/cli/argument-parser');3createTestCafe('localhost', 1337, 1338)4 .then(testcafe => {5 .createRunner()6 .src(options.src)7 .browsers(options.browsers)8 .run(options)9 .then(failedCount => {10 console.log('Tests failed: ' + failedCount);11 testcafe.close();12 });13 });14const createTestCafe = require('testcafe');15const parseOptions = require('testcafe/lib/cli/argument-parser');16createTestCafe('localhost', 1337, 1338)17 .then(testcafe => {18 .createRunner()19 .src(options.src)20 .browsers(options.browsers)21 .run(options)22 .then(failedCount => {23 console.log('Tests failed: ' + failedCount);24 testcafe.close();25 });26 });27const createTestCafe = require('testcafe');28const parseOptions = require('testcafe/lib/cli/argument-parser');29createTestCafe('localhost', 1337, 1338)30 .then(testcafe => {31 .createRunner()32 .src(options.src)33 .browsers(options.browsers)34 .run(options)35 .then(failedCount => {36 console.log('Tests failed: ' + failedCount);37 testcafe.close();38 });39 });40const createTestCafe = require('testcafe');41const parseOptions = require('testcafe/lib/cli/argument-parser');42const options = parseOptions(['--test', 'test.js', '--

Full Screen

Using AI Code Generation

copy

Full Screen

1const parseOptions = require('testcafe/lib/cli/argument-parser');2const createTestCafe = require('testcafe');3createTestCafe('localhost', 1337, 1338)4 .then(testcafe => {5 .createRunner()6 .src('test.js')7 .browsers('chrome')8 .run();9 });10import { Selector } from 'testcafe';11test('My first test', async t => {12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var parseOptions = require('testcafe/lib/cli/argument-parser').parseOptions;2var options = parseOptions(['--test', 'test.js', '--browser', 'chrome', '--test-reporter', 'json']);3var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;4var runner = createLiveModeRunner(options);5var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;6var runner = createLiveModeRunner(options);7var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;8var runner = createLiveModeRunner(options);9var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;10var runner = createLiveModeRunner(options);11var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;12var runner = createLiveModeRunner(options);13var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;14var runner = createLiveModeRunner(options);15var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;16var runner = createLiveModeRunner(options);17var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;18var runner = createLiveModeRunner(options);19var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;20var runner = createLiveModeRunner(options);21var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;22var runner = createLiveModeRunner(options);23var createLiveModeRunner = require('testcafe/lib/live').createLiveModeRunner;

Full Screen

Using AI Code Generation

copy

Full Screen

1const createTestCafe = require('testcafe');2const path = require('path');3async function parseOptions() {4 const testCafe = await createTestCafe('localhost', 1337, 1338);5 const runner = testCafe.createRunner();6 .src(path.join(__dirname, 'test.js'))7 .browsers('chrome')8 .run({9 });10}11parseOptions();12const createTestCafe = require('testcafe');13const path = require('path');14async function parseOptions() {15 const testCafe = await createTestCafe('localhost', 1337, 1338);16 const runner = testCafe.createRunner();17 .src(path.join(__dirname, 'test.js'))18 .browsers('chrome')19 .run({

Full Screen

Using AI Code Generation

copy

Full Screen

1var parseOptions = require('testcafe')2 .createLiveModeRunner()3 .src('tests/test.js')4 .browsers('chrome')5 .run()6 .then(function (failed) {7 console.log('Tests failed: ' + failed);8 process.exit(failed ? 1 : 0);9 });10parseOptions.parseOptions(process.argv);11var parseOptions = require('testcafe')12 .createLiveModeRunner()13 .src('tests/test.js')14 .browsers('chrome')15 .run()16 .then(function (failed) {17 console.log('Tests failed: ' + failed);18 process.exit(failed ? 1 : 0);19 });20parseOptions.parseOptions(process.argv);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseOptions } from 'testcafe';2const options = parseOptions('testcafe chrome test.js --fixture-meta fixture=fixture1', { allowUnrecognizedOptions: true });3console.log(options);4import { createTestCafe } from 'testcafe';5let testcafe = null;6createTestCafe('localhost', 1337, 1338)7 .then(tc => {8 testcafe = tc;9 const runner = testcafe.createRunner();10 .src('test.js')11 .browsers('chrome')12 .run();13 })14 .then(failedCount => {15 console.log('Tests failed: ' + failedCount);16 testcafe.close();17 });18import { createLiveModeRunner } from 'testcafe';19createLiveModeRunner()20 .src('test.js')21 .browsers('chrome')22 .run()23 .then(() => {24 console.log('Tests finished');25 });26createLiveModeRunner()27import { createLiveModeRunner } from 'testcafe';28createLiveModeRunner()29 .src('test.js')30 .browsers('chrome')31 .run()32 .then(() => {33 console.log('Tests finished');34 });35createBrowserConnection()36import { createBrowserConnection } from 'testcafe';37const connection = createBrowserConnection();38 .once('ready', async () => {39 .createRunner()40 .src('test.js')41 .browsers(connection)42 .run();43 });44console.log(connection.url);45createTestCafe(hostname, port1, port2)46`hostname` *(optional)* | String | The hostname used to

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcafe automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful