samedi 21 mai 2016

Configuring testem for ember app

I am having a hellish time trying to configure my ember app to run tests through testem. I have looked high and low and cannot seem to find more then surface level documentation. I think this fundamentally stems from a lack of understanding on a deep level what ember build is doing which I'm also having trouble finding documentation on.

Right now my testem.json looks like this

{
  "framework": "qunit",
  "disable_watching": true,
  "debug": true,
  "src_files": [
    "dist/assets/vendor.js",
    "config/environment.js",
    "app-name.js",
    "dist/assets/test-support.js",
    "dist/assets/test-loader.js",
    "dist/assets/tests.js"
  ],
  "launch_in_ci": [
    "PhantomJS"
  ],
  "launch_in_dev": [
    "PhantomJS",
    "Chrome"
  ]
}

which leads to an error being thrown: Global error: Error: Could not find module `app-name/config/environment` imported from `app-name/tests/helpers/resolver` at http://localhost:7357/dist/assets/vendor.js, line 151

However I don't believe there is anything weird going on with my config. It has no problem being exported and imported when running the app outside of test mode.

My other attempt has been to load through a test page ala

{
  "framework": "qunit",
  "test_page": "tests/index.html?hidepassed",
  "disable_watching": true,
  "launch_in_ci": [
    "PhantomJS"
  ],
  "launch_in_dev": [
    "PhantomJS",
    "Chrome"
  ]
}

This seems to be the default but this just renders the contents of my index.html in the browser but my handlebars do not get prepocessed and it doesn't seem like any of the scripts on the page get loaded either. Basically it seems to pull in the page as raw text and does not run any tests or anything at all.

For reference my tests/index.html looks like:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>App-name</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    
    

    <link rel="stylesheet" href="assets/vendor.css">
    <link rel="stylesheet" href="assets/app-name.css">
    <link rel="stylesheet" href="assets/test-support.css">

    
    
  </head>
  <body>
    
    

    <script src="assets/vendor.js"></script>
    <script src="assets/test-support.js"></script>
    <script src="assets/app-name.js"></script>
    <script src="testem.js" integrity=""></script>
    <script src="assets/tests.js"></script>
    <script src="assets/test-loader.js"></script>

    
    
  </body>
</html>

I'm looking for advice on:

a) If I'm doing something obviously dumb b) If anyone has any documentation for ember build or testem past what are posted on the top level docs of those projects c) ESPECIALLY: If anyone has projects they can point me to that has a working version of a similar setup




Aucun commentaire:

Enregistrer un commentaire