How to use getTransformRuntimeOpts method in Testcafe

Best JavaScript code snippet using testcafe

Run Testcafe automation tests on LambdaTest cloud grid

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

load-libs.js

Source: load-libs.js Github

copy
1import EXPORTABLE_LIB_PATH from '../test-file/exportble-lib-path';
2
3function getPresetEnvForTestCodeOpts () {
4    return {
5        targets: { node: 'current' },
6        loose:   true,
7        exclude: ['transform-regenerator']
8    };
9}
10
11function getPresetEnvForClientFunctionOpts () {
12    return {
13        loose:   true,
14        exclude: ['transform-typeof-symbol']
15    };
16}
17
18function getModuleResolverOpts () {
19    return {
20        resolvePath (source) {
21            if (source === 'testcafe')
22                return EXPORTABLE_LIB_PATH;
23
24            return source;
25        }
26    };
27}
28
29
30function getTransformRuntimeOpts () {
31    // NOTE: We are forced to import helpers to each compiled file
32    // because of '@babel/plugin-transform-runtime' plugin cannot correctly resolve path
33    // to the helpers from the '@babel/runtime' module.
34    return {
35        'helpers': false
36    };
37}
38
39function getPresetReact () {
40    const presetReact = require('@babel/preset-react');
41
42    presetReact.presets = []; // disables flow so it doesn't confict w/ presetFlow
43
44    return presetReact;
45}
46
47// NOTE: lazy load heavy dependencies
48export default function loadLibs () {
49    return {
50        babel:                      require('@babel/core'),
51        presetStage2:               require('./preset-stage-2'),
52        presetFlow:                 require('@babel/preset-flow'),
53        transformRuntime:           [require('@babel/plugin-transform-runtime'), getTransformRuntimeOpts()],
54        transformForOfAsArray:      require('babel-plugin-transform-for-of-as-array').default,
55        presetEnvForClientFunction: [require('@babel/preset-env'), getPresetEnvForClientFunctionOpts()],
56        presetEnvForTestCode:       [require('@babel/preset-env'), getPresetEnvForTestCodeOpts()],
57        moduleResolver:             [require('babel-plugin-module-resolver'), getModuleResolverOpts()],
58        presetReact:                getPresetReact()
59    };
60}
61
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 Testcafe 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)