Finally got my code tested while being able to load it in the browser. I have a couple more questions!

  1. Since requireing is not an issue anymore, I felt that it’s a good idea to separate classes from the main.js file into their own files (Foo.js and Bar.js). is this a good idea?

  2. How do I name the test files? (For now, I just named them Foo.test.js and Bar.test.js)

  3. Another naming question: How do I name the source and the transpiled scripts? Currently, I just ran browserify main.js -o app.js then linked app.js on my index.html

  4. class Foo has an active method that listens for click events. How do I test this?

  5. class Foo takes HTML(jQuery) elements as constructor parameters. What should I pass when testing Foo?

  6. Last slightly unrelated question: I have a vendor folder on my repository that contains external stuff (bootstrap, jquery, font-awesome etc.). How do I create a branch named local (contains vendor folder) and production (uses CDN) without manually copy pasting each components?

Thanks! <3

Since requireing is not an issue anymore, I felt that it’s a good idea to separate classes from the main.js file into their own files (Foo.js and Bar.js). is this a good idea?

Definitely a good idea
Here’s a nice post that explains why:
https://medium.freecodecamp.com/javascript-modules-a-beginner-s-guide-783f7d7a5fcc#.4vj2f18ox

How do I name the test files? (For now, I just named them Foo.test.js and Bar.test.js)

Another naming question: How do I name the source and the transpiled scripts? Currently, I just ran browserify main.js -o app.js then linked app.js on my index.html

The convention is to put test files in test directory that mirrors the structure of tested files. Each file should end with .test.js

Alternatively. check your favorite open source project on github for inspiration. They’ll definitely have tests there.

class Foo has an active method that listens for click events. How do I test this?

class Foo takes HTML(jQuery) elements as constructor parameters. What should I pass when testing Foo?

Last slightly unrelated question: I have a vendor folder on my repository that contains external stuff (bootstrap, jquery, font-awesome etc.). How do I create a branch named local (contains vendor folder) and production (uses CDN) without manually copy pasting each components?

Prepare two build configs, one for production and one for development.

1 Like

You are amazing. Thanks for the help! :sunny: