How to use moduleB method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

Run Webdriverio automation tests on LambdaTest cloud grid

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

install-actions.js

Source: install-actions.js Github

copy
1'use strict'
2var npm = require('../../lib/npm.js')
3var log = require('npmlog')
4var test = require('tap').test
5
6var mockLog = {
7  finish: function () {},
8  silly: function () {}
9}
10
11var actions
12test('setup', function (t) {
13  npm.load(function () {
14    log.disableProgress()
15    actions = require('../../lib/install/actions.js').actions
16    t.end()
17  })
18})
19
20test('->optdep:a->dep:b', function (t) {
21  var moduleA = {
22    name: 'a',
23    path: '/a',
24    package: {
25      scripts: {
26        postinstall: 'false'
27      },
28      dependencies: {
29        b: '*'
30      }
31    },
32    isTop: true
33  }
34  var moduleB = {
35    name: 'b',
36    path: '/b',
37    package: {},
38    requires: [],
39    requiredBy: [moduleA]
40  }
41  moduleA.requires = [moduleB]
42
43  var tree = {
44    path: '/',
45    package: {
46      optionalDependencies: {
47        a: '*'
48      }
49    },
50    children: [moduleA, moduleB],
51    requires: [moduleA],
52    isTop: true
53  }
54  moduleA.requiredBy = [tree]
55  moduleA.parent = tree
56  moduleB.parent = tree
57
58  t.plan(3)
59  return actions.postinstall('/', moduleA, mockLog).then(() => {
60    throw new Error('was not supposed to succeed')
61  }, (err) => {
62    t.is(err && err.code, 'ELIFECYCLE', 'Lifecycle failed')
63    t.ok(moduleA.failed, 'moduleA (optional dep) is marked failed')
64    t.ok(moduleB.failed, 'moduleB (direct dep of moduleA) is marked as failed')
65    t.end()
66  })
67})
68
69test('->dep:b,->optdep:a->dep:b', function (t) {
70  var moduleA = {
71    name: 'a',
72    path: '/',
73    package: {
74      scripts: {
75        postinstall: 'false'
76      },
77      dependencies: {
78        b: '*'
79      }
80    },
81    isTop: false
82  }
83  var moduleB = {
84    name: 'b',
85    path: '/',
86    package: {},
87    requires: [],
88    requiredBy: [moduleA],
89    isTop: false
90  }
91  moduleA.requires = [moduleB]
92
93  var tree = {
94    path: '/',
95    package: {
96      dependencies: {
97        b: '*'
98      },
99      optionalDependencies: {
100        a: '*'
101      }
102    },
103    children: [moduleA, moduleB],
104    requires: [moduleA, moduleB],
105    isTop: true
106  }
107  moduleA.requiredBy = [tree]
108  moduleB.requiredBy.push(tree)
109  moduleA.parent = tree
110  moduleB.parent = tree
111
112  t.plan(3)
113  return actions.postinstall('/', moduleA, mockLog).then(() => {
114    throw new Error('was not supposed to succeed')
115  }, (err) => {
116    t.ok(err && err.code === 'ELIFECYCLE', 'Lifecycle failed')
117    t.ok(moduleA.failed, 'moduleA (optional dep) is marked failed')
118    t.ok(!moduleB.failed, 'moduleB (direct dep of moduleA) is marked as failed')
119    t.end()
120  })
121})
122
Full Screen

test-module-circular-symlinks.js

Source: test-module-circular-symlinks.js Github

copy
1'use strict';
2
3// This tests to make sure that modules with symlinked circular dependencies
4// do not blow out the module cache and recurse forever. See issue
5// https://github.com/nodejs/node/pull/5950 for context. PR #5950 attempted
6// to solve a problem with symlinked peer dependencies by caching using the
7// symlink path. Unfortunately, that breaks the case tested in this module
8// because each symlinked module, despite pointing to the same code on disk,
9// is loaded and cached as a separate module instance, which blows up the
10// cache and leads to a recursion bug.
11
12// This test should pass in Node.js v4 and v5. It should pass in Node.js v6
13// after https://github.com/nodejs/node/pull/5950 has been reverted.
14
15const common = require('../common');
16const assert = require('assert');
17const path = require('path');
18const fs = require('fs');
19
20// {tmpDir}
21// ├── index.js
22// └── node_modules
23//     ├── moduleA
24//     │   ├── index.js
25//     │   └── node_modules
26//     │       └── moduleB -> {tmpDir}/node_modules/moduleB
27//     └── moduleB
28//         ├── index.js
29//         └── node_modules
30//         └── moduleA -> {tmpDir}/node_modules/moduleA
31
32const tmpdir = require('../common/tmpdir');
33tmpdir.refresh();
34const tmpDir = tmpdir.path;
35
36const node_modules = path.join(tmpDir, 'node_modules');
37const moduleA = path.join(node_modules, 'moduleA');
38const moduleB = path.join(node_modules, 'moduleB');
39const moduleA_link = path.join(moduleB, 'node_modules', 'moduleA');
40const moduleB_link = path.join(moduleA, 'node_modules', 'moduleB');
41
42fs.mkdirSync(node_modules);
43fs.mkdirSync(moduleA);
44fs.mkdirSync(moduleB);
45fs.mkdirSync(path.join(moduleA, 'node_modules'));
46fs.mkdirSync(path.join(moduleB, 'node_modules'));
47
48try {
49  fs.symlinkSync(moduleA, moduleA_link);
50  fs.symlinkSync(moduleB, moduleB_link);
51} catch (err) {
52  if (err.code !== 'EPERM') throw err;
53  common.skip('insufficient privileges for symlinks');
54}
55
56fs.writeFileSync(path.join(tmpDir, 'index.js'),
57                 'module.exports = require(\'moduleA\');', 'utf8');
58fs.writeFileSync(path.join(moduleA, 'index.js'),
59                 'module.exports = {b: require(\'moduleB\')};', 'utf8');
60fs.writeFileSync(path.join(moduleB, 'index.js'),
61                 'module.exports = {a: require(\'moduleA\')};', 'utf8');
62
63// Ensure that the symlinks are not followed forever...
64const obj = require(path.join(tmpDir, 'index'));
65assert.ok(obj);
66assert.ok(obj.b);
67assert.ok(obj.b.a);
68assert.ok(!obj.b.a.b);
69
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Webdriverio on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)