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

Make tests work without input/output files #97

Open
phillipskevin opened this issue Mar 21, 2018 · 1 comment
Open

Make tests work without input/output files #97

phillipskevin opened this issue Mar 21, 2018 · 1 comment
Assignees

Comments

@phillipskevin
Copy link
Contributor

It would be really nice if we could just use template literals for tests, instead of requiring new files for every test and updates to the transforms file:

{
"input": "can-component-rename/input.js",
"outputPath": "can-component-rename/can-component-rename-input.js",
"type": "fixture",
"version": "3"
},
{
"input": "can-component-rename/output.js",
"outputPath": "can-component-rename/can-component-rename-output.js",
"type": "fixture",
"version": "3"
},

It would be nice if you could just do something like

runTests("can-stache/console-log", [{
  in: `
    {{log}}
  `,
  out: `
    {{console.log(this)}}
  `
}, {
  in: `
    {{log(foo)}}
  `,
  out: `
    {{console.log(foo)}}
  `
}];

This would make it much easier to add new tests and would make it more likely for people to add new tests.

@Mattchewone
Copy link
Contributor

Looking over the repo and want to make some notes on what is happening:

  • Files are written in src
  • Generate compiles/babelises the source and outputs to lib
  • Tests are copied into the lib alongside the transform
  • Test input/outputs are copied into fixtures
  • Tests file requires are added to the test/test.js file for mocha to run

If we are to remove the extra in/out files in favour of writing them inline within the test file, we would need to remove the step to move these files into fixtures.
We would need to pull the content and put it into a method that would run the transform with the in/out source being the content. The diffFiles util would need to be modified with one that would read the source in/out from a string as opposed to reading from a file.

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

No branches or pull requests

2 participants