Skip to content

fix: do not require ts-jest and typescript #307

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

Merged
merged 5 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions e2e/__projects__/babel-in-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"test": "jest --no-cache test.js"
},
"dependencies": {
"vue": "3.0.0-alpha.10"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.3",
"jest": "^24.0.0"
"jest": "^24.0.0",
"ts-jest": "^26.4.4",
"typescript": "^4.1.2",
"vue": "3.0.0-alpha.10"
},
"jest": {
"moduleFileExtensions": [
Expand Down
252 changes: 250 additions & 2 deletions e2e/__projects__/babel-in-package/yarn.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions e2e/__projects__/basic/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var _default = {
exports[\\"default\\"] = _default;
\\"use strict\\";
Object.defineProperty(exports, \\"__esModule\\", { value: true });
exports.render = void 0;
var vue_1 = require(\\"vue\\");
var _hoisted_1 = { class: \\"hello\\" };
function render(_ctx, _cache) {
Expand Down Expand Up @@ -77,6 +78,7 @@ var _default = {
exports[\\"default\\"] = _default;
\\"use strict\\";
Object.defineProperty(exports, \\"__esModule\\", { value: true });
exports.render = void 0;
var vue_1 = require(\\"vue\\");
var _hoisted_1 = { class: \\"hello\\" };
function render(_ctx, _cache) {
Expand Down
2 changes: 2 additions & 0 deletions e2e/__projects__/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"jest": "^24.0.0",
"ts-jest": "^26.4.4",
"typescript": "^4.1.2",
"vue-class-component": "^8.0.0-beta.4"
},
"jest": {
Expand Down
252 changes: 250 additions & 2 deletions e2e/__projects__/basic/yarn.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const constants = require('./constants')
const loadPartialConfig = require('@babel/core').loadPartialConfig
const { resolveSync: resolveTsConfigSync } = require('tsconfig')
const chalk = require('chalk')
const path = require('path')
const fs = require('fs')
Expand Down Expand Up @@ -64,6 +65,11 @@ const getBabelOptions = function loadBabelOptions(filename, options = {}) {
}

const getTsJestConfig = function getTsJestConfig(config) {
const isUsingTs = resolveTsConfigSync(process.cwd())
Copy link
Contributor

Choose a reason for hiding this comment

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

Should support tsconfig not place at root dir.
If run npm run jest, process.cwd() always be root dir. I put tsconfig file at <rootDir>/sub.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is a problem. We should support something like

// jest.config.js
module.exports = {  
  globals: {
    'vue-jest': {
      tsconfig: './some/path/tsconfig.json'
    }
  }
}

Would you like to make a PR? I can review + release when it's done. If I need to do it, it might take a while, I have a few other projects I need to work on like Test Utils 2.0.0 release etc. I'd really appreciate the help!

if (!isUsingTs) {
return null
}

const createTransformer = require('ts-jest').createTransformer
const tr = createTransformer()
const configSet = tr.configsFor(config)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"sass": "^1.23.7",
"semantic-release": "^15.13.2",
"stylus": "^0.54.5",
"typescript": "^3.2.2",
"ts-jest": "^26.4.4",
"typescript": "^4.1.2",
"vue": "^3.0.3"
},
"peerDependencies": {
Expand All @@ -80,7 +81,7 @@
"chalk": "^2.1.0",
"convert-source-map": "^1.6.0",
"extract-from-css": "^0.4.4",
"ts-jest": "^24.0.0"
"tsconfig": "^7.0.0"
},
"repository": {
"type": "git",
Expand Down
Loading