cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Read only

ReferenceError: sap is not defined

saibhanu
Advisor
Advisor
0 Likes
575

Hello Experts,

our pipeline is failing with below error in the karma step 

as we are using piper template to run our pipeline we are using KarmaExecutetests step

when we are the tests in local it is running fine but when we run in the pipeline it failing with below error

Chrome Headless 139.0.0.0 (Linux 0.0.0) ERROR
info karmaExecuteTests - Uncaught ReferenceError: sap is not defined
info karmaExecuteTests - at webapp/test/unit/unitTests.qunit.js:1:1
info karmaExecuteTests -
info karmaExecuteTests - ReferenceError: sap is not defined
info karmaExecuteTests - at webapp/test/unit/unitTests.qunit.js:1:1

please find the logs for better understanding attached
below is unittest.qunit.html file
<!DOCTYPE html>
<html>

<head>
	<title>Unit tests</title>
	<meta http-equiv='X-UA-Compatible' content='IE=edge'>
	<meta charset="utf-8">

	<script 
		id="sap-ui-bootstrap"
		src="../../../../resources/sap-ui-core.js"
		data-sap-ui-libs="sap.m"
		data-sap-ui-resourceroots='{
			"exemptiontool.exemptiontool": "../../",
			"test/unit": "./"
		}'>
		</script>

	<script src="../../../../resources/sap/ui/qunit/qunit-css.js"></script>
	<script src="../../../../resources/sap/ui/thirdparty/qunit.js"></script>
	<script src="../../../../resources/sap/ui/qunit/qunit-junit.js"></script>
	<script src="../../../../resources/sap/ui/qunit/qunit-coverage.js"></script>

	<script>
		QUnit.config.autostart = false;

		sap.ui.require(
			["test/unit/allTests"],
			function () {
				QUnit.start();
			}
		);
	</script>

</head>

<body>
	<ol id="qunit-tests"></ol>
	<div id="qunit-fixture"></div>
</body>

</html>

below is opa5.qunit.html

<!DOCTYPE html>
<html>
<head>
    <title>Integration tests</title>
    <meta charset="utf-8">

    <script id="sap-ui-bootstrap"
            src="../../../../resources/sap-ui-core.js"
            data-sap-ui-theme='sap_fiori_3'
            data-sap-ui-resourceroots='{
                "exemptiontool.exemptiontool": "../../"
            }'
            data-sap-ui-animation="false"
            data-sap-ui-compatVersion="edge"
            data-sap-ui-async="true">
    </script>

    <link rel="stylesheet" type="text/css" href="../../../../resources/sap/ui/thirdparty/qunit-2.css">

    <script src="../../../../resources/sap/ui/thirdparty/qunit-2.js"></script>
    <script src="../../../../resources/sap/ui/qunit/qunit-junit.js"></script>

    <script src="opaTests.qunit.js"></script>

</head>
<body>
    <div id="qunit"></div>
    <div id="qunit-fixture"></div>
</body>
</html>


could you please help me here
Best Regards,
Bhanu.

View Entire Topic
Julien-Gagnier
Explorer
0 Likes

Hi

This error means the SAPUI5 framework is not found

../../../../resources/sap-ui-core.js

 I suppose it is working fine in your test environment, but from your pipeline, it won't be the same environment.

To test, please replace the relative path with the following one:

https://ui5.sap.com/xx/resources/sap-ui-core.js

xx would be the version you want (or nothing to use the last one)

Best regards

saibhanu
Advisor
Advisor
0 Likes

Let me check and get back to you

I have checked it not it is failing with script error 

any idea that we can resolve this as well

below is the error message

Chrome Headless 139.0.0.0 (Linux 0.0.0) ERROR
info karmaExecuteTests - Script error.
info karmaExecuteTests - at :0:0
let me know if you need any more info