Results 1 to 4 of 4

Thread: Node.JS require functionality

  1. #1
    Sencha User
    Join Date
    Mar 2017
    Posts
    28
    Vote Rating
    1
      1  

    Default Node.JS require functionality

    I have a few repetitive cleanup functions that perform simple actions like .setValue(''); that I want to place in an external lib file for reuse in multiple scenarios throughout my project. Can someone provide an example of the Node.js require syntax needed in the lib file and how I use that file in my scenarios?

    The external lib file is named test3.js and this is the clearTextfield function I'm trying to reuse:
    Code:
    'use strict';
    var lm = {
    // remove value from given component - This applies to textfield
        clearTextfield(locator) {
                locator
            .and(function(locator) {
                locator.setValue('');
            });
        }
    
    
    
    
    typeAndValidation(locator, text) {
    //type text into field identified by its locator
            it(locator + ' should be editable', function () {
                stpo.ProviderRegistrationLocators(locator)
                .type(text)
                .and(function(cmp){
                expect(cmp.getValue()).toBe(text);
                });
            });
        
        }
    };
    
    
    module.exports = lm;
    My attempt to require the module in my scenario:

    Code:
    describe('forms', function() {    
        beforeAll(function(done){
            var lm = require('./lib/test3');
            done();
        });
    Trying to call the 'clearTextfield' function from the module:
    Code:
    describe('Provider email and confirmation', function() {
            
            it('Enter invalid email format for provider', function(){
                stpo.ProviderRegistrationLocators.providerEmail()
                    .type('cookie')
                    .and(function(textfield){
                        expect(textfield.isValid()).toBeFalsy();
                        lm.clearTextfield(stpo.ProviderRegistrationLocators.providerEmail());
                    });
                stpo.ProviderRegistrationLocators.providerEmail()
                    .type('@email.com')
                    .and(function(textfield) {
                        expect(textfield.isValid()).toBeFalsy();
                        lm.clearTextfield(stpo.ProviderRegistrationLocators.providerEmail());
                    });
            });
    
    
        });

  2. #2
    Sencha User
    Join Date
    Mar 2017
    Posts
    28
    Vote Rating
    1
      0  

    Default

    Is this thing on? I really don't want to use my support credits for a question that Subu said he'd write a blog about during one of his demos.

  3. #3
    Sencha User
    Join Date
    Mar 2017
    Posts
    28
    Vote Rating
    1
      0  

    Default

    One last try. Can anyone provide some input on this functionality?

  4. #4
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    253
    Answers
    32
    Vote Rating
    31
      1  

    Default

    Please see the example below.

    If, for example, we have a "Helper.js" file under one of our Scenarios in the "lib" folder containing this code:

    Code:
    'use strict';
    
    
    module.exports = class Helper {
        locateGrid(locator) {
            return ST.grid(locator);
        }
    };
    It's possible to "require" and use the above class in one of the test suites like this:

    Code:
    describe('Grid', function() {
        var Helper = require('./lib/Helper.js'),
            helper = new Helper();
        
        it('Should find the grid', function() {
            helper.locateGrid('grid');
        });
    });
    I hope this helps.
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

Similar Threads

  1. Ext.require
    By disallowed in forum Ext 6: Q&A
    Replies: 3
    Last Post: 10 Jul 2015, 12:40 AM
  2. Replies: 3
    Last Post: 2 Jul 2012, 4:09 AM
  3. [SOLVED] Require and CallBack
    By g13013 in forum Ext: Discussion
    Replies: 2
    Last Post: 11 Mar 2012, 4:40 AM
  4. Ext 4 and the Ext.require
    By pasblin in forum Ext: Discussion
    Replies: 4
    Last Post: 30 Apr 2011, 4:08 AM
  5. require on Ext JS 4
    By slmbakop in forum Ext: Discussion
    Replies: 0
    Last Post: 9 Mar 2011, 7:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •