-
Notifications
You must be signed in to change notification settings - Fork 62
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
this.element.querySelectorAll is not a function #109
Comments
Can you post the entire component you're testing? |
I'm getting the same error. I'm in a bit of a Vue + TypeScript + Jest tangle, so it could be something else. My component and spec are as follows: <template>
<div>
{{ test }}
<span></span>
<router-view/>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import Header from '@/components/Header';
export default Vue.extend({
name: 'App',
components: { Header },
data() {
return {
test: 'Teeesting',
};
},
});
</script> import { shallow } from 'avoriaz';
import App from '../App';
describe('App.vue', () => {
it('should contain a div', () => {
const wrapper = shallow(App);
expect(wrapper.contains('div')).toEqual(true);
});
});
It sounds like an async thing. Before using Avoriaz I needed to use I'm not using a browser to test, but I believe Jest brings jsdom with it. Am I supposed to test the components directly, or somehow test the webpack bundle? Do I need to put the test specs through Babel or just TypeScript before they go to Jest if I'm using ES modules? Sorry, I'm having some trouble wrapping my head around the specifics of unit testing. Many thanks if you can help. |
I believe the issue is that App isn't compile correctly. Do you get any other errors? |
The app was building fine for development and production as far as I can remember. It is now, and I've not changed much. I have swapped out Avoriaz for vue-test-utils and managed to get tests working (just changed |
Yep Vue Test Utils is based off avoriaz. You're better of using Vue Test Utils, so I'm glad it was easy for you to migrate 👍 |
code :
expect(wrapper.contains('p')).toBe(true);
error: this.element.querySelectorAll is not a function
version: 3.2.0
The text was updated successfully, but these errors were encountered: