What do you need to know if a prospective employer asks you to take a test?
First of all, although it doesn't make sense to try to "game" the assessments (after all, if you misrepresent yourself, you may either be flagged by the assessments as "faking" your personality, and/or end up in a job or at an organization that isn't a good fit for you), it is helpful to know what kinds of dimensions are assessed by well established pre-employment tests.
It can also be helpful to know how these tests reflect your personality. Here is a well-established free assessment of the Big Five personality dimensions. The report will be instructive about how you come across on this kind of assessment.
Secondly, you need to know your legal rights. You can always refuse to take a personality or cognitive ability test, but the prospective employer is then free to end your candidacy. Employers have an obligation to follow certain legal guidelines with respect to pre-employment assessment.
Finally, it's important to understand that the assessments an organization uses to assess you might be more diagnostic of the organization than of you. By understanding the criteria the organization considers important, you get valuable information about the organization as well, and this can help you determine fit as well.
For a more in-depth discussion about personality testing for the purposes of pre-employment assessment, you may find this radio program of interest.