0

Since I have install jasmine LTS from sfdx am using jasmine/2.6.1 . Write a test as said in the example for c:egGlobalValueProvider But I am getting an error in scratch org :TypeError: component.find is not a function

  <aura:application>
    <c:lts_jasmineRunner testFiles="{!join(',', 
    $Resource.jasmineHelloWorldTests
)}" />
 </aura:application>

and in lts_JasmineRunner.cmp :

<aura:component extensible="true">
    <aura:attribute name="testFiles" type="String[]" required="true" description="list of test spec files"/>

    <!--  placeholder div which example test specs use to render components under test -->
    <div aura:id="renderTestComponents" id="renderTestComponents"></div>

    <!-- Placeholder div for jasmine test results  -->
    <div id="jasmineHtmlTestResults"/>

    <!-- Pull in jasmine, utils and the test specs specified by the consuming wrapper test app  -->
    <ltng:require scripts="{!join(',', 
        $Resource.lts_jasmine + '/lib/jasmine-2.6.1/jasmine.js',
        $Resource.lts_jasmine + '/lib/jasmine-2.6.1/jasmine-html.js',
        $Resource.lts_jasmineboot,
        $Resource.lts_testutil,
        v.testFiles
    )}"
        styles="{!join(',', 
        $Resource.lts_jasmine + '/lib/jasmine-2.6.1/jasmine.css'
    )}"
        afterScriptsLoaded="{!c.runTests}" />

</aura:component>

jasmineHelloWorldTests.js

describe("Lightning Component Testing Examples", function(){

    describe('c:egGlobalValueProvider', function(){
        it('renders a custom label', function(done) {
            debugger;
            $T.createComponent("c:egGlobalValueProvider", {}, true)
            .then(function(component){

                //var that=this;

                var greetingLabelVal = $A.get("$Label.c.greeting");
                expect(greetingLabelVal).toBeTruthy(greetingLabelVal);

                component.set('v._recordId','asdasd');

                expect(component.get("v._recordId")).toBe('asdasd');
               expect(component.find("greeting").getElement().textContent).toBe(greetingLabelVal);
                done();
            }).catch(function(e) {
                done.fail(e);
            });
        });
    });




});

Lightning component :

 <aura:attribute name="_recordId" type="String" />
    {!v._recordId}
    Helloooooo
    <div aura:id="greeting">{!$Label.c.greeting}</div>
</aura:component>

Got this error : enter image description here

i though its about version of jasmin but after upgrade to 3.0.0 also getting same error

Note : update sfdx and install lts too

  • Could you please copy and paste the relevant source code and error messages into your question, using Ctrl-K or the {} tool to format them, rather than posting screenshots? – David Reed Nov 30 '18 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.