GithubHelp home page GithubHelp logo

Comments (2)

Krinkle avatar Krinkle commented on September 25, 2024 1

@matthewcornell I generally recommend against use of non-standard JavaScript.

However, QUnit does not mind if you use alternative JavaScript compilation targets such as CoffeeScript, TypeScript, Webpack-customised imports, or Babel (for new Ecma syntax in current browsers). In that case, you will have to build your source code first and import the output of your build process in your test suite, rather than your underlying source files. This is similar to what your application would do, and makes the test more representative of what your application will be experiencing as well.

There are a number of different ways to do this. When testing your code within Node.js, you can use the --require option of the QUnit CLI to register an automatic pre-processing step that will automatically handle Babel and TypeScript. I don't recall if Webpack supports something like this, if it does, you could use that.

Otherwise, you may have to add an explicit step before your test command. For example, in package.json, you might write

"test": "esbuild && qunit"

Or,

"build": "webpack …",
"test": "npm run build && qunit",
"test-watch": "qunit -w",

Naturally, you can combine the watch modes as well. For example, you might have npm run build-watch open in one terminal tab, and npm run test-watch open in another.

from qunit.

matthewcornell avatar matthewcornell commented on September 25, 2024

Following up, I believe I got this working by extracting import './mystyles.css'; to a separate .js file and then adding that file to the webpack.config.cjs's entry section. Note that the order in that section was significant. I would still welcome your comments, thanks.

from qunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.