Can't figure out where to put require.config when using TypeScript, RequireJs, and Jasmine -


i've been following pattern setting typescript, requirejs, , jasmine steve fenton describes here:

https://www.stevefenton.co.uk/content/blog/date/201407/blog/combining-typescript-jasmine-and-amd-with-requirejs/

that pattern worked , unblocked me (yay!), i'm @ point need customize settings requirejs can't seem figure out put require.config call. everywhere i've tried has caused breaks , regressions. here 2 approaches seem logical/promising

in specrunner.cshtml

<script data-main="/scripts/typescript/requirejsconfig" src="/scripts/require.js"></script> 

in requirejsconfig.ts

require.config({     baseurl: "../scripts",     paths: {         jquery: "../jquery-2.1.3"     } });  // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // attempt 1: when try way error // //     javascript runtime error: object doesn't support property or method 'config' // import testloader = require("tests/testloader"); testloader.run();  // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // attempt 2: when try way, builds , runs without errors,  // jasmine doesn't find of tests.  "no specs found"  // though see breakpoints on "it" statements getting hit. // require(["tests/testloader"], (testloader) => {     testloader.run(); });  // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  jasmine.getenv().execute(); 

in testloader.ts

import guidhelpertests = require("tests/t3/helpers/guidhelpertests"); import objecthelpertests = require("tests/t3/helpers/objecthelpertests");  class testloader {      public static run: () => void = () => {         guidhelpertests.run();         objecthelpertests.run();     }     }  export var run = () => testloader.run(); 

in guidhelpertests.ts

import t3 = require("t3/t3lib");  export var run = () => {      describe("guidhelper tests", () => {         it("guid validator validates guid", () => {          // etc. ...  

my guess attempt 2 doesn't work because of kind of sequencing issue test discovery process happening before modules loaded, or that. i'm not versed enough in requirejs know options here.

i prefer keep configuration away application - can pre-register configuration this, , picked requirejs when loads. no need add first file.

<script> var require = {     baseurl: "../scripts",     paths: {         jquery: "../jquery-2.1.3"     } }; </script> <script data-main="/scripts/typescript/requirejsconfig" src="/scripts/require.js"></script> 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -