Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for require. #102

Closed
wants to merge 2 commits into from
Closed

Test for require. #102

wants to merge 2 commits into from

Conversation

stillesjo
Copy link
Contributor

Tests for functionality introduced in 044d6b6

A temporary .js-file is created before each test and removed afterwards. The tests will try to import the temporary file with or without the ./-prefix and also once when the js-file is missing.

The tests are written in a new js-file in order to have before and afterEach-methods. If you prefer to have them in the test.js-file I can move them there.

beforeEach(function(){
tempFile = temp.path({dir:process.cwd(), suffix: '.js'});
tempFileBaseName = path.basename(tempFile);
fs.closeSync(fs.openSync(tempFile, 'w'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More succinct to just use https://github.com/sindresorhus/temp-write

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want an empty file in the current working directory. temp-write seems to write the the tmp-directory of the running OS.

Importing the file using the whole path works before 044d6b6 so I don't feel that the test would cover the case I was having trouble with.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. Nvm.

@stillesjo
Copy link
Contributor Author

@sindresorhus
Updated after your review. Left out changing to temp-write just yet, see discussion above.

@sindresorhus
Copy link
Owner

Looks good. Thanks :)

sindresorhus added a commit that referenced this pull request Jul 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants