Skip to content
This repository has been archived by the owner on May 25, 2020. It is now read-only.

Running tests against obfuscated code #21

Open
brian-mann opened this issue Feb 16, 2015 · 2 comments
Open

Running tests against obfuscated code #21

brian-mann opened this issue Feb 16, 2015 · 2 comments

Comments

@brian-mann
Copy link

I was wondering how you would approach running tests against the obfuscated code.

For instance, while all my tests pass prior to obfuscation, after doing so it's possible I broke something. Using __dirname would point to a potentially incorrect path.

To avoid these headaches I was attempting to run all of my unit tests against the obfuscated code, but that doesn't work due to the require paths being completely wrong in the unit tests. I was wondering if you could give me some direction at solving this.

Because the single entry point is exported, it seems impossible to get access to the require'd files from outside of the file.

@stephenmathieson
Copy link
Owner

i have only run acceptance tests after obfuscating a project. e.g. things that test the "app" directly, not its individual modules.

To avoid these headaches I was attempting to run all of my unit tests against the obfuscated code, but that doesn't work due to the require paths being completely wrong in the unit tests. I was wondering if you could give me some direction at solving this.

depending on how your app/tests are structured, you may be able to put a "phony" entry together which require()s all of your tests:

require('./test/my-test-1')
require('./test/my-test-2')
require('./test/my-test-3')

it seems impossible to get access to the require'd files from outside of the file.

yes, that's (mostly) true. without massive hackery, you no longer have access.


sorry i don't have a good solution for this. i'll think a bit more about tomorrow. :/

@brian-mann
Copy link
Author

Okay thanks for the response. I'll have some time to keep hacking on it pretty soon, and I'll let you know if I get anywhere.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants